(AGK version: Studio)
Submitted: 2022-01-11 00:13:18
// Project: memblockSound 
// Created: 22-01-10 by jd_zoo

// show all errors

SetErrorMode(2)

// set window properties
SetWindowTitle( "memblockSound" )
SetWindowSize( 640, 480, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 640, 480 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )

SetPrintSize(18)

bits_numChannel as float = 0.0
bits_bitsPerSample as float = 0.0
bits_samplesPerSecond as float = 0.0
bits_numFrames as float = 0.0

sound_length as float = 0.0

mySound = LoadSound("armo_mono.wav")
myMemBlock = CreateMemblockFromSound(mySound)

bits_numChannel = GetMemblockByte(myMemBlock, 0)						//Number of Channels (1 or 2)
bits_bitsPerSample = GetMemblockByte(myMemBlock, 2)						//Bit Depth (example: 16bit)
bits_samplesPerSecond = GetMemblockInt(myMemBlock, 4)					//Sample Rate (example: 44100)
bits_numFrames = GetMemblockInt(myMemBlock, 8)							//Number of frames in the sound data

sound_length = bits_numFrames / bits_samplesPerSecond

do
    
    print("bits_numChannels = " + str(bits_numChannel, 0))
    print("bits_bitsPerSample = " + str(bits_bitsPerSample, 0))
    print("bits_samplesPerSecond = " + str(bits_samplesPerSecond, 0))
    print("bits_numFrames = " + str(bits_numFrames, 0))
    print(chr(10) + "sound_length = " + str(sound_length) + " seconds")
    
    Sync()
    
loop
Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.