WRITE...

Previous topic - Next topic

S. P. Gardebiter

Hab ein wenig mit meinem FMS programm rumgespielt und ich musst leider einen ziemlich üblen Fehler feststellen O_o

Code (glbasic) Select
// --------------------------------- //
// Project: Frequency Modulation Music 44
// Start: Sunday, October 12, 2008
// IDE Version: 5.360


Count = 0
CountX = 0
CountY = 0

SampleRate = 44100

TotalLength = 0

// Für Noten und erzeugung des Tones
DIM Volume[8192]
DIM Frequency[8192]
DIM Length[8192]
DIM Volume[8192]
DIM Note[120]
DIM Samples[13230000][2]
// Für die Frequenz Modulations Synthese
DIM FMS[16]
DIM FMFrequency[16]
DIM FMFineTune[16]
DIM FMShift[16]
DIM FMVolume[16]

// Noten, Notenlänge und Lautstärke definieren
Frequency[0] = 39
Frequency[1] = 42
Frequency[2] = 44
Frequency[3] = 46
Frequency[4] = 47
Frequency[5] = 51
Frequency[6] = 44
Frequency[7] = 51
Frequency[8] = 56
Frequency[9] = 58
Frequency[10] = 59
Frequency[11] = 56
Frequency[12] = 58
Frequency[13] = 54
Frequency[14] = 51
Frequency[15] = 44
Frequency[16] = 46
Frequency[17] = 47
Frequency[18] = 51
Frequency[19] = 44
Frequency[20] = 43
Frequency[21] = 44
Frequency[22] = 46
Frequency[23] = 47
Frequency[24] = 51
Frequency[25] = 47
Frequency[26] = 46
Frequency[27] = 44
Frequency[28] = 46
Frequency[29] = 47
Frequency[30] = 49
Frequency[31] = 51
Frequency[32] = 54
Frequency[33] = 56
Length[0] = 2
Length[1] = 2
Length[2] = 8
Length[3] = 2
Length[4] = 2
Length[5] = 4
Length[6] = 10
Length[7] = 2
Length[8] = 2
Length[9] = 2
Length[10] = 4
Length[11] = 4
Length[12] = 4
Length[13] = 4
Length[14] = 16
Length[15] = 8
Length[16] = 2
Length[17] = 2
Length[18] = 4
Length[19] = 8
Length[20] = 8
Length[21] = 2
Length[22] = 2
Length[23] = 2
Length[24] = 2
Length[25] = 2
Length[26] = 2
Length[27] = 2
Length[28] = 2
Length[29] = 2
Length[30] = 2
Length[31] = 2
Length[32] = 2
Length[33] = 8
Volume[0] = 20000
Volume[1] = 20000
Volume[2] = 20000
Volume[3] = 20000
Volume[4] = 20000
Volume[5] = 20000
Volume[6] = 20000
Volume[7] = 20000
Volume[8] = 20000
Volume[9] = 20000
Volume[10] = 20000
Volume[11] = 20000
Volume[12] = 20000
Volume[13] = 20000
Volume[14] = 20000
Volume[15] = 20000
Volume[16] = 20000
Volume[17] = 20000
Volume[18] = 20000
Volume[19] = 20000
Volume[20] = 20000
Volume[21] = 20000
Volume[22] = 20000
Volume[23] = 20000
Volume[24] = 20000
Volume[25] = 20000
Volume[26] = 20000
Volume[27] = 20000
Volume[28] = 20000
Volume[29] = 20000
Volume[30] = 20000
Volume[31] = 20000
Volume[32] = 20000
Volume[33] = 20000

// Notenfrequenz

Note[0] = 27.5

FOR Count = 1 TO 119
Note[Count] = 1.059463094359 * Note[Count-1]
NEXT

// Für die Modulationssynthese: Frequenz, Phasenverschiebung und Lautstärke

FMFrequency[0] = 12
FMFrequency[1] = -12
FMFrequency[2] = 0
FMShift[0] = 0
FMShift[1] = 50
FMShift[2] = 0
FMVolume[0] = 1
FMVolume[1] = 1
FMVolume[2] = 0.5

FOR Count = 0 TO 33
INC TotalLength, Length[Count][0]
NEXT

REDIM Samples[TotalLength*44100/10][2]

IF OPENFILE(1, "Output.wav", FALSE) // Save output

                // Nach diesem Code hier wird nichts mehr gespeichert:

FOR CountX = 0 TO 33
FOR CountY = 0 TO Length[CountX][0] * 44100 / 10
INC Count, 1
FMS[0] = (SIN(360/SampleRate*Count*Note[Frequency[CountX]+FMFrequency[0]]+FMShift[0])*Volume[CountX]*FMVolume[0])
FMS[1] = (SIN(360/SampleRate*Count*Note[Frequency[CountX]+FMFrequency[1]]+FMShift[1])*Volume[CountX]*FMVolume[1])
FMS[2] = SIN(360/SampleRate*Count*Note[Frequency[CountX]+FMFrequency[2]]+FMShift[2])
IF FMS[2] >= 0
FMS[2] = (1*Volume[CountX]*FMVolume[2])
ELSE
FMS[2] = (0*Volume[CountX]*FMVolume[2])
ENDIF
Samples[Count][1] = (FMS[0]+FMS[1]+FMS[2])/3
Samples[Count][0] = Samples[Count][1]
NEXT
NEXT

WRITEBYTE 1, 5 // Wird ignoriert und nicht als Datei gespeichert...

ENDIF


Bitte einmal nach ganz unten scrollen.
Weiß jemand warum? O_o
~ Cave Story rules! ~

Kitty Hello

Mit V6 oder V5?
Sollte in V6 gehen. Schau mal, ob ein CLOSEFILE am Ende hilft?

S. P. Gardebiter

Ich hab Version 5 und das Online Update sagt mir auch das die Version aktuell ist O_o
Wo krieg ich 6 her? ;)

Naja, Closefile hilft auch nichts, hab ich schon probiert...
~ Cave Story rules! ~

Kitty Hello

Im IRC Chat "? betasdk" eingeben.

Schranz0r

QuoteVolume[0] = 20000
   Volume[1] = 20000
   Volume[2] = 20000
   Volume[3] = 20000
   Volume[4] = 20000
   Volume[5] = 20000
   Volume[6] = 20000
   Volume[7] = 20000
   Volume[8] = 20000
   Volume[9] = 20000
   Volume[10] = 20000
   Volume[11] = 20000
   Volume[12] = 20000
   Volume[13] = 20000
   Volume[14] = 20000
   Volume[15] = 20000
   Volume[16] = 20000
   Volume[17] = 20000
   Volume[18] = 20000
   Volume[19] = 20000
   Volume[20] = 20000
   Volume[21] = 20000
   Volume[22] = 20000
   Volume[23] = 20000
   Volume[24] = 20000
   Volume[25] = 20000
   Volume[26] = 20000
   Volume[27] = 20000
   Volume[28] = 20000
   Volume[29] = 20000
   Volume[30] = 20000
   Volume[31] = 20000
   Volume[32] = 20000
   Volume[33] = 20000

Mir wird schlecht :D

*öhm* For-Schleife  :nana:
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

#5
If CountX=33, If CountY=35246, If Count=582120
When  these are true....this next line causes the crash:
Samples[Count][1] = (FMS[0]+FMS[1]+FMS[2])/3

:enc:

I hope you can figgure out why it is crashing, this is a really interesting program.

Bing ChatGpt is pretty smart :O

Kitty Hello

You allocate 100 MB - is that really needed?

S. P. Gardebiter

#7
Quote from: Kitty Hello on 2008-Oct-14
Im IRC Chat "? betasdk" eingeben.

Danke.

Quote from: Schranz0r on 2008-Oct-14Mir wird schlecht :D

*öhm* For-Schleife  :nana:

Schon erledigt.

Quote from: Hemlos on 2008-Oct-14If CountX=33, If CountY=35246, If Count=582120
When  these are true....this next line causes the crash:
Samples[Count][1] = (FMS[0]+FMS[1]+FMS[2])/3

Uh...? I have no idea, normally it should work.

Quote from: Kitty Hello on 2008-Oct-14
You allocate 100 MB - is that really needed?

Yes, I think about 200 MB.
200 MB are for a 10 Minute Sound File.
And no that's not needed, I will edit it :)

Edit: Es funktioniert immer noch nicht :/ Selbst mit GLBasic V6 nicht.
~ Cave Story rules! ~

Kitty Hello

Der springt hier raus:
            Samples[Count][1] = (FMS[0]+FMS[1]+FMS[2])/3
Weil Count >= BOUNDS(Samples[], 0) wird.

Pack's mal nicht in ein Feld, sondern schreib die Daten direkt raus.

S. P. Gardebiter

Quote from: Kitty Hello on 2008-Oct-15
Der springt hier raus:
            Samples[Count][1] = (FMS[0]+FMS[1]+FMS[2])/3
Weil Count >= BOUNDS(Samples[], 0) wird.

Pack's mal nicht in ein Feld, sondern schreib die Daten direkt raus.

Ich frag mich warum er kleiner ist als der Array ist.
Ich kann die daten nicht direkt ausgeben, weil ich sie für die bearbeitung zusammenschneiden will (Zweites Instrument z.B.). Andernfalls muss ich was sehr umständliches machen.
~ Cave Story rules! ~

Kitty Hello

OK, dann nimm mit V6 wenigstens ein array von DGNat. Also arr%[].

S. P. Gardebiter

Quote from: Kitty Hello on 2008-Oct-15
OK, dann nimm mit V6 wenigstens ein array von DGNat. Also arr%[].


DIM Samples%[2][2]?
~ Cave Story rules! ~

Kitty Hello

Jo so. Oder:
LOCAL Samples%[]
...

Das % ist dannach optional - nur beim ersten Mal, wenn der Precompiler ein % findet wird der Variablentyp festgelegt und dann konsequent beibehalten:

LOCAL a%
a = 5 // greift jetzt auf a% zu.

Schranz0r

Mehrere Instrumente... Types?
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

#14
Any luck yet  S. P. Gardebiter
Did you figgure out if its a bug with glbasic using the debugger?

Did you try using gernots latest suggestion using samples%[]?

Im interested to see this work.

BTW if you do get it to work, may i suggest making a midi format sound generator?
Theres alot of sound features like, music instruments, ocean waves, and gunshots, helicopters etc etc etc Its all built into the midi drivers already, i think all you need to do is the same thing youre trying here with the wav, building with "write"...
...im working on such a midi program, however, my way requires me to parse data into a 3rd party program to create the file, using a text formated input. I dont like it this way using a second program, but I dont really understand the way write works.
Bing ChatGpt is pretty smart :O