Gibt es irgendeine Möglichkeit, (zumindest unter Windows) einen Sound per GLBasic Programm erstellen zu lassen bzw. gleich abzuspielen? Hat jemand mit sowas schonmal Erfahrungen gemacht?
Edit: Wahrscheinlich brauch ich dazu das .wav File Format oder? :P
Moin Moin,
schau Dir mal das hier an http://www.glbasic.com/showroom.php?game=SoundRecorder&site=games&lang=de (http://www.glbasic.com/showroom.php?game=SoundRecorder&site=games&lang=de)
aber sonst wüsste ich nicht das GLB das von Haus aus kann,
nur über Include oder Dll.
Im Showroom gibts noch was mit "FMod", vieleicht hilft das auch weiter.
Danke, ich werd mich mal umsehen. :D
Eigentlich meinte ich ja, dass das Programm z.B. eine Sinus Kurve erstellt und dann als .wav oder so speichert.
Nein, direkt weiß ich keinen Weg.
was willst du genau machen ?
Ich poste einfach mal den Code:
// --------------------------------- //
// Project: SE44
// Start: Sunday, October 05, 2008
// IDE Version: 5.360
Count = 0
CountX = 0
CountY = 0
NumSamples = 65536
DIM Sample[NumSamples]
ChunkID$ = "RIFF" // big endian Integer
ChunkSize = 0 // little endian Integer
Form$ = "WAVE" // big endian Integer
SubChunk1ID$ = "fmt " // big endian Integer
SubChunk1Size = 16 // little endian Integer
AudioFormat = 1 // little endian Word
NumChannels = 1 // little endian Word
SampleRate = 44100 // little endian Integer
ByteRate = 0 // little endian Integer
BlockAlign = 0 // little endian Word
BitsPerSample = 8 // little endian Word
BlockAlign = NumChannels * BitsPerSample / 8
ByteRate = SampleRate * BlockAlign
SubChunk2ID$ = "data" // big endian Integer
SubChunk2Size = NumSamples * BlockAlign // little endian Integer
ChunkSize = 4 + (8 + SubChunk1Size) + (8 + SubChunk2Size)
CountX = 112 // Generating square wave
FOR Count = 0 TO NumSamples - 1
Sample[Count] = CountX
IF CountY < 63
INC CountY, 1
ELSE
IF CountX = 112
CountX = 144
ELSE
CountX = 112
ENDIF
CountY = 0
ENDIF
NEXT
IF OPENFILE(1, "Output.wav", FALSE) // Save output
WRITESTR 1, ChunkID$
WRITELONG 1, ChunkSize
WRITESTR 1, Form$
WRITESTR 1, SubChunk1ID$
WRITELONG 1, SubChunk1Size
WRITEWORD 1, AudioFormat
WRITEWORD 1, NumChannels
WRITELONG 1, SampleRate
WRITELONG 1, ByteRate
WRITEWORD 1, BlockAlign
WRITEWORD 1, BitsPerSample
WRITESTR 1, SubChunk2ID$
WRITELONG 1, SubChunk2Size
FOR Count = 0 TO NumSamples - 1
WRITEBYTE 1, Sample[Count]
NEXT
ENDIF
IF OPENFILE(1, "Debug.log", FALSE) // Debug information
WRITELINE 1, "ChunkID: " + ChunkID$
WRITELINE 1, "ChunkSize: " + ChunkSize
WRITELINE 1, "Form: " + Form$
WRITELINE 1, ""
WRITELINE 1, "SubChunk1ID: " + SubChunk1ID$
WRITELINE 1, "SubChunk1Size: " + SubChunk1Size
WRITELINE 1, "AudioFormat: " + AudioFormat
WRITELINE 1, "NumChannels: " + NumChannels
WRITELINE 1, "SampleRate: " + SampleRate
WRITELINE 1, "ByteRate: " + ByteRate
WRITELINE 1, "BlockAlign: " + BlockAlign
WRITELINE 1, "BitsPerSample: " + BitsPerSample
WRITELINE 1, ""
WRITELINE 1, "SubChunk2ID: " + SubChunk2ID$
WRITELINE 1, "SubChunk2Size: " + SubChunk2Size
WRITELINE 1, ""
WRITELINE 1, "Samples: "
WRITELINE 1, ""
FOR Count = 0 TO NumSamples - 1
WRITESTR 1, Sample[Count]
NEXT
ENDIF
Es erzeugt eine PCM, Mono, 8-bit, 44100 Hz Wave Datei, in der eine Rechteck Kurve enthalten ist.
Das Problem ist nur das bei ihr die Chunksize nicht stimmt und deshalb will Winamp sie nicht richtig laden <_<
Ich hab keine Ahnung wieso...
SubChunk2Size = NumSamples * BlockAlign // little endian Integer
ChunkSize = 4 + (8 + SubChunk1Size) + (8 + SubChunk2Size)
FOR Count = 0 TO NumSamples - 1
WRITEBYTE 1, Sample[Count]
NEXT
Beantwortet das deine Frage? ;)
Irgendwie stimmt die SubChunk2 und die Chunksize nicht D:
Sample ist in dem Fall ein DGInt ;)
Also −2.147.483.648 bis 2.147.483.647 [edit] ein 64 bit double.
Schau doch mal, Gernot hat mal irgendwo ein Bank geschrieben...
Glaub das ist im Inline-schnipsel-Forum :)
:|
Da ist /me wohl ins Fettnäpfchen getreten... :S
Danke für den Edit Gernot :D
Have you gotten these programs working yet?
The .wav dont seem to play anything audible.
Quote from: Hemlos on 2008-Oct-15
Have you gotten these programs working yet?
The .wav dont seem to play anything audible.
I know :/ It's the ChunkSize which isn't correct, it's always too small and I have no idea why:
NumSamples = 65536
BlockAlign = NumChannels * BitsPerSample / 8
SubChunk2Size = NumSamples * BlockAlign
ChunkSize = 4 + (8 + SubChunk1Size) + (8 + SubChunk2Size)
But every time the Chunksize is 0x24 in the file. Alltough you can see here it should be over 65536.
WRITELONG 1, SubChunk2Size
Shouldn't that be ChunkSize, you're writing?
Quote from: Kitty Hello on 2008-Oct-15
WRITELONG 1, SubChunk2Size
Shouldn't that be ChunkSize, you're writing?
Look into the code. I write both, the ChunkSize and the SubChunk2Size in it :)
But both haven't got the correct size when saved into the .wav.
Turn on the DEBUG mode, and DEBUG some of the values.
Is it a bug in GLBasic?
Seems to be... Debugger tells me the correct number, but the numbers aren't correct in the file itself.
44316 is 24 or something in the file :/
Edit: What the- It works in V6.
öhhhhhhhhh.....
Deutsches Forum?!
V6 ftw!
Quote from: S. P. Gardebiter on 2008-Oct-15
Edit: What the- It works in V6.
Nice.
The code from first page is working?