Commit 2be3a89

Nick committed on
DMF stuf
commit 2be3a899aa0295f2f8c94e8388bed117b9044bd5 parent 06b9566
4 changed files +49−26
Modifieddmfimport.pas +29−6
@@ -5,7 +5,7 @@ unit DMFImport;
5 interface 5 interface
6 6
7 uses 7 uses
8 Classes, SysUtils, ZStream, Song, hUGEDataTypes, Constants; 8 Classes, SysUtils, ZStream, Song, Instruments, hUGEDataTypes, Constants;
9 9
10 type 10 type
11 EDMFException = class(Exception); 11 EDMFException = class(Exception);
@@ -110,6 +110,9 @@ begin
110 Result.Instruments.Wave[I+1].Name := TempS; 110 Result.Instruments.Wave[I+1].Name := TempS;
111 Result.Instruments.Noise[I+1].Name := TempS; 111 Result.Instruments.Noise[I+1].Name := TempS;
112 112
113 // TODO
114 Result.Instruments.Wave[I+1].Waveform := 0;
115
113 // 1 Byte: Instrument Mode (0 = STANDARD INS, 1 = FM INS) 116 // 1 Byte: Instrument Mode (0 = STANDARD INS, 1 = FM INS)
114 if DS.ReadByte <> 0 then 117 if DS.ReadByte <> 0 then
115 raise EDMFException.Create('DMF file contains a non-standard instrument!'); 118 raise EDMFException.Create('DMF file contains a non-standard instrument!');
@@ -153,7 +156,19 @@ begin
153 //1 Byte: Envelope Direction 156 //1 Byte: Envelope Direction
154 //1 Byte: Envelope Length 157 //1 Byte: Envelope Length
155 //1 Byte: Sound Length 158 //1 Byte: Sound Length
156 DS.Seek(4, soCurrent); 159 with Result.Instruments.Duty[I+1] do begin
160 InitialVolume := DS.ReadByte;
161
162 VolSweepDirection := TSweepType(DS.ReadByte);
163 if VolSweepDirection = stUp then
164 VolSweepDirection := stDown
165 else
166 VolSweepDirection := stUp;
167
168 VolSweepAmount := TEnvelopeSweepAmount(DS.ReadByte);
169 //Length := DS.ReadByte;
170 DS.Seek(1, soCurrent);
171 end;
157 end; 172 end;
158 173
159 //WAVETABLES DATA 174 //WAVETABLES DATA
@@ -163,8 +178,14 @@ begin
163 // Repeat this WAVETABLE_SIZE times 178 // Repeat this WAVETABLE_SIZE times
164 // 4 Bytes: Wavetable Data 179 // 4 Bytes: Wavetable Data
165 TotalWavetables := DS.ReadByte; 180 TotalWavetables := DS.ReadByte;
166 for I := 0 to TotalWavetables-1 do 181 for I := 0 to TotalWavetables-1 do begin
167 DS.Seek(DS.ReadDWord * 4, soCurrent); 182 Temp := DS.ReadDWord;
183 writeln('wave length was ', temp);
184 for J := 0 to Temp-1 do begin
185 writeln(i, ' ', j);
186 Result.Waves[I, J] := Byte(DS.ReadDWord);
187 end;
188 end;
168 189
169 for I := Low(TOrderMatrix) to High(TOrderMatrix) do begin 190 for I := Low(TOrderMatrix) to High(TOrderMatrix) do begin
170 Temp := DS.readbyte; 191 Temp := DS.readbyte;
@@ -182,7 +203,7 @@ begin
182 if (DmfNote = 0) and (DmfOctave = 0) then 203 if (DmfNote = 0) and (DmfOctave = 0) then
183 Note := NO_NOTE 204 Note := NO_NOTE
184 else 205 else
185 Note := DmfNote + (12*DmfOctave) - (12*3); 206 Note := DmfNote + (12*DmfOctave) - (12*2);
186 207
187 DS.Seek(2,soCurrent); //volume 208 DS.Seek(2,soCurrent); //volume
188 209
@@ -196,7 +217,9 @@ begin
196 217
197 Instrument := Byte(DS.ReadWord); 218 Instrument := Byte(DS.ReadWord);
198 if Instrument = High(Byte) then 219 if Instrument = High(Byte) then
199 Instrument := 0; 220 Instrument := 0
221 else
222 Inc(Instrument);
200 end; 223 end;
201 end; 224 end;
202 end; 225 end;
Modifiedinstruments.pas +4−4
@@ -10,7 +10,7 @@ uses
10 type 10 type
11 TInstrumentType = (itSquare = 0, itWave = 1, itNoise = 2); 11 TInstrumentType = (itSquare = 0, itWave = 1, itNoise = 2);
12 TDutyType = 0..3; 12 TDutyType = 0..3;
13 TSweepType = (Up, Down); 13 TSweepType = (stUp, stDown);
14 TStepWidth = (swFifteen, swSeven); 14 TStepWidth = (swFifteen, swSeven);
15 TEnvelopeVolume = 0..15; 15 TEnvelopeVolume = 0..15;
16 TEnvelopeSweepAmount = 0..7; 16 TEnvelopeSweepAmount = 0..7;
@@ -316,7 +316,7 @@ begin
316 316
317 NR42.InitialVolume := Instr.InitialVolume; 317 NR42.InitialVolume := Instr.InitialVolume;
318 NR42.SweepNumber := Instr.VolSweepAmount; 318 NR42.SweepNumber := Instr.VolSweepAmount;
319 NR42.Direction := Instr.VolSweepDirection = Up; 319 NR42.Direction := Instr.VolSweepDirection = stUp;
320 320
321 NR43.ShiftClockFrequency := $F - (Frequency shr 7); // Quantize CH4 note 321 NR43.ShiftClockFrequency := $F - (Frequency shr 7); // Quantize CH4 note
322 322
@@ -352,12 +352,12 @@ begin
352 352
353 NR10.SweepTime := Instr.SweepTime; 353 NR10.SweepTime := Instr.SweepTime;
354 NR10.Shift := Instr.SweepShift; 354 NR10.Shift := Instr.SweepShift;
355 NR10.IncDec := Instr.SweepIncDec = Down; 355 NR10.IncDec := Instr.SweepIncDec = stDown;
356 356
357 NR11.Duty := Instr.Duty; 357 NR11.Duty := Instr.Duty;
358 NR11.Length := Instr.Length; 358 NR11.Length := Instr.Length;
359 359
360 NR12.Direction := Instr.VolSweepDirection = Up; 360 NR12.Direction := Instr.VolSweepDirection = stUp;
361 NR12.InitialVolume := Instr.InitialVolume; 361 NR12.InitialVolume := Instr.InitialVolume;
362 NR12.SweepNumber := Instr.VolSweepAmount; 362 NR12.SweepNumber := Instr.VolSweepAmount;
363 363
Modifiedsong.pas +6−6
@@ -391,11 +391,11 @@ begin
391 Length := 0; 391 Length := 0;
392 LengthEnabled := False; 392 LengthEnabled := False;
393 InitialVolume := High(TEnvelopeVolume); 393 InitialVolume := High(TEnvelopeVolume);
394 VolSweepDirection := Down; 394 VolSweepDirection := stDown;
395 VolSweepAmount := 0; 395 VolSweepAmount := 0;
396 396
397 SweepTime := 0; 397 SweepTime := 0;
398 SweepIncDec := Down; 398 SweepIncDec := stDown;
399 SweepShift := 0; 399 SweepShift := 0;
400 400
401 Duty := 2; 401 Duty := 2;
@@ -419,7 +419,7 @@ begin
419 Length := 0; 419 Length := 0;
420 LengthEnabled := False; 420 LengthEnabled := False;
421 InitialVolume := High(TEnvelopeVolume); 421 InitialVolume := High(TEnvelopeVolume);
422 VolSweepDirection := Down; 422 VolSweepDirection := stDown;
423 VolSweepAmount := 0; 423 VolSweepAmount := 0;
424 NoiseMacro := Default(TNoiseMacro); 424 NoiseMacro := Default(TNoiseMacro);
425 ShiftClockFreq := 0; 425 ShiftClockFreq := 0;
@@ -537,11 +537,11 @@ begin
537 Length := 0; 537 Length := 0;
538 LengthEnabled := False; 538 LengthEnabled := False;
539 InitialVolume := High(TEnvelopeVolume); 539 InitialVolume := High(TEnvelopeVolume);
540 VolSweepDirection := Down; 540 VolSweepDirection := stDown;
541 VolSweepAmount := 0; 541 VolSweepAmount := 0;
542 542
543 SweepTime := 0; 543 SweepTime := 0;
544 SweepIncDec := Down; 544 SweepIncDec := stDown;
545 SweepShift := 0; 545 SweepShift := 0;
546 546
547 Duty := 2; 547 Duty := 2;
@@ -565,7 +565,7 @@ begin
565 Length := 0; 565 Length := 0;
566 LengthEnabled := False; 566 LengthEnabled := False;
567 InitialVolume := High(TEnvelopeVolume); 567 InitialVolume := High(TEnvelopeVolume);
568 VolSweepDirection := Down; 568 VolSweepDirection := stDown;
569 VolSweepAmount := 0; 569 VolSweepAmount := 0;
570 ShiftClockFreq := 0; 570 ShiftClockFreq := 0;
571 DividingRatio := 0; 571 DividingRatio := 0;
Modifiedtracker.pas +10−10
@@ -648,13 +648,13 @@ begin
648 end 648 end
649 else begin 649 else begin
650 case CurrentInstrument^.VolSweepDirection of 650 case CurrentInstrument^.VolSweepDirection of
651 Down: begin // Envelope down, check length cut 651 stDown: begin // Envelope stDown, check length cut
652 For I := 0 to V do 652 For I := 0 to V do
653 LineTo( Min(I*S,L)*Interval, H-(V-I)*HInterval); 653 LineTo( Min(I*S,L)*Interval, H-(V-I)*HInterval);
654 LineTo(W, H); 654 LineTo(W, H);
655 LineTo(Trunc(L*Interval), H); 655 LineTo(Trunc(L*Interval), H);
656 end; 656 end;
657 Up: begin // Envelope up, check length cut 657 stUp: begin // Envelope stUp, check length cut
658 For I := 0 to 15-V do 658 For I := 0 to 15-V do
659 LineTo( Min(I*S,L)*Interval, (15-V-I)*HInterval+9); 659 LineTo( Min(I*S,L)*Interval, (15-V-I)*HInterval+9);
660 LineTo(L*Interval, H-15*HInterval); 660 LineTo(L*Interval, H-15*HInterval);
@@ -1173,8 +1173,8 @@ begin
1173 1173
1174 StartVolTrackbar.Position := CI^.InitialVolume; 1174 StartVolTrackbar.Position := CI^.InitialVolume;
1175 case CI^.VolSweepDirection of 1175 case CI^.VolSweepDirection of
1176 Up: DirectionComboBox.Text := 'Up'; 1176 stUp: DirectionComboBox.Text := 'Up';
1177 Down: DirectionComboBox.Text := 'Down'; 1177 stDown: DirectionComboBox.Text := 'Down';
1178 end; 1178 end;
1179 EnvChangeTrackbar.Position := CI^.VolSweepAmount; 1179 EnvChangeTrackbar.Position := CI^.VolSweepAmount;
1180 1180
@@ -1182,8 +1182,8 @@ begin
1182 itSquare: begin 1182 itSquare: begin
1183 SweepTimeCombobox.ItemIndex := CI^.SweepTime; 1183 SweepTimeCombobox.ItemIndex := CI^.SweepTime;
1184 case CI^.SweepIncDec of 1184 case CI^.SweepIncDec of
1185 Up: SweepDirectionCombobox.Text := 'Up'; 1185 stUp: SweepDirectionCombobox.Text := 'Up';
1186 Down: SweepDirectionCombobox.Text := 'Down'; 1186 stDown: SweepDirectionCombobox.Text := 'Down';
1187 end; 1187 end;
1188 SweepSizeTrackbar.Position := CI^.SweepShift; 1188 SweepSizeTrackbar.Position := CI^.SweepShift;
1189 DutyCombobox.ItemIndex := CI^.Duty; 1189 DutyCombobox.ItemIndex := CI^.Duty;
@@ -1319,8 +1319,8 @@ end;
1319 procedure TfrmTracker.SweepDirectionComboboxChange(Sender: TObject); 1319 procedure TfrmTracker.SweepDirectionComboboxChange(Sender: TObject);
1320 begin 1320 begin
1321 case SweepDirectionComboBox.Text of 1321 case SweepDirectionComboBox.Text of
1322 'Up': CurrentInstrument^.SweepIncDec := Up; 1322 'Up': CurrentInstrument^.SweepIncDec := stUp;
1323 'Down': CurrentInstrument^.SweepIncDec := Down; 1323 'Down': CurrentInstrument^.SweepIncDec := stDown;
1324 end; 1324 end;
1325 EnvelopePaintBox.Invalidate; 1325 EnvelopePaintBox.Invalidate;
1326 end; 1326 end;
@@ -1570,8 +1570,8 @@ end;
1570 procedure TfrmTracker.DirectionComboBoxChange(Sender: TObject); 1570 procedure TfrmTracker.DirectionComboBoxChange(Sender: TObject);
1571 begin 1571 begin
1572 case DirectionComboBox.Text of 1572 case DirectionComboBox.Text of
1573 'Up': CurrentInstrument^.VolSweepDirection := Up; 1573 'Up': CurrentInstrument^.VolSweepDirection := stUp;
1574 'Down': CurrentInstrument^.VolSweepDirection := Down; 1574 'Down': CurrentInstrument^.VolSweepDirection := stDown;
1575 end; 1575 end;
1576 EnvelopePaintBox.Invalidate; 1576 EnvelopePaintBox.Invalidate;
1577 end; 1577 end;