Sound erstellen lassen und abspielen?

Previous topic - Next topic

S. P. Gardebiter

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
~ Cave Story rules! ~

D2O

Moin Moin,
schau Dir mal das hier an 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.
I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell

S. P. Gardebiter

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.
~ Cave Story rules! ~

Kitty Hello

Nein, direkt weiß ich keinen Weg.

Schranz0r

was willst du genau machen ?
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

S. P. Gardebiter

Ich poste einfach mal den Code:

Code (glbasic) Select
// --------------------------------- //
// 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...
~ Cave Story rules! ~

S. P. Gardebiter

#6
Code (glbasic) Select
SubChunk2Size = NumSamples * BlockAlign // little endian Integer

Code (glbasic) Select
ChunkSize = 4 + (8 + SubChunk1Size) + (8 + SubChunk2Size)

Code (glbasic) Select
FOR Count = 0 TO NumSamples - 1
WRITEBYTE 1, Sample[Count]
NEXT


Beantwortet das deine Frage? ;)

Irgendwie stimmt die SubChunk2 und die Chunksize nicht D:
~ Cave Story rules! ~

Schranz0r

#7
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 :)

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Schranz0r

 :|

Da ist /me wohl ins Fettnäpfchen getreten...  :S

Danke für den Edit Gernot :D
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Hemlos

Have you gotten these programs working yet?
The .wav dont seem to play anything audible.
Bing ChatGpt is pretty smart :O

S. P. Gardebiter

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:

Code (glbasic) Select
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.
~ Cave Story rules! ~

Kitty Hello

WRITELONG 1, SubChunk2Size

Shouldn't that be ChunkSize, you're writing?

S. P. Gardebiter

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.
~ Cave Story rules! ~

Kitty Hello

Turn on the DEBUG mode, and DEBUG some of the values.
Is it a bug in GLBasic?

S. P. Gardebiter

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.
~ Cave Story rules! ~