@Rick
today i got error at code example upload, i tryed relogin but the error stay.
Quote: "Whoops, looks like something went wrong."
example was
2017.09.25
tier1
#option_explicit
rem AGK 2017.9.25
rem MR 10.12.2017
//create sound wave in memory
sec as integer
sec = 1
data as integer
data = sec * (44100 * (2*2)) // 176400 bytes per second
frames as integer
frames = data / 4
size as integer
size = 2+2+4+4 + data
local mem as integer
mem = CreateMemblock(size)
SetMemblockByte(mem,0, 2) //The first 2 bytes of the memlbock store the number of channels (1 or 2 supported)
SetMemblockByte(mem,1, 0)
SetMemblockByte(mem,2,16) //the next 2 bytes store the bits per sample (8 (1 byte) or 16 (2 byte) supported)
SetMemblockByte(mem,3, 0)
SetMemblockint(mem,4,44100) // the next 4 bytes store the samples per second, for example 44100
SetMemblockint(mem,8,frames) // The next 4 bytes are the number of frames in the sound data, the size of the sound data in bytes can be calculated from this with the formula numFrames*(bitsPerSample/8)*channels.
local i as integer
local value as integer
value=0
local w as float
w=0
local Hz as float
Hz = 8000.0
for i=0 to data -1 step 4
w=w+(360.0 / 44100.0) * Hz
if w > 360.0 then w = w -360.0
value = sin(w)*32767.0 //Max −32768 through 32767
SetMemblockShort(mem,12+i+0 ,value) // short 2 bytes −32768 through 32767
SetMemblockShort(mem,12+i+2 ,value) // short 2 bytes −32768 through 32767
next
sound as integer
sound = CreateSoundFromMemblock(mem)
PlaySound(sound,100,1)
Do
p("sec",str(sec))
p("data",str(data))
p("size",str(size))
p("frames",str(frames))
p("mem",str(mem))
p("sound",str(sound))
print("playing sound, click mouse to exit")
if GetPointerPressed() then exit
sync()
Loop
end
Function p(name$,text$)
print (name$+":"+text$)
EndFunction
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)