Timing is correct now! Forgot to update samples_per_tick when parsing the 0xf effect.
[pineappletracker.git] / hively / hvl_replay.h.bak
blob6ae5b41ce185f20d565fe2927a779d06867a691d
1 #include "types.h"
2 // Woohoo!
3 #define MAX_CHANNELS 16
5 #define Period2Freq(period) ((3546897.f * 65536.f) / (period)) 
7 struct hvl_envelope
9   int16 aFrames, aVolume;
10   int16 dFrames, dVolume;
11   int16 sFrames;
12   int16 rFrames, rVolume;
13   int16 pad;
16 struct hvl_plsentry
18   uint8 ple_Note;
19   uint8 ple_Waveform;
20   int16 ple_Fixed;
21   int8  ple_FX[2];
22   int8  ple_FXParam[2];
25 struct hvl_plist
27   int16                pls_Speed;
28   int16                pls_Length;
29   struct hvl_plsentry *pls_Entries;
32 struct hvl_instrument
34   TEXT                ins_Name[128];
35   uint8               ins_Volume;
36   uint8               ins_WaveLength;
37   uint8               ins_FilterLowerLimit;
38   uint8               ins_FilterUpperLimit;
39   uint8               ins_FilterSpeed;
40   uint8               ins_SquareLowerLimit;
41   uint8               ins_SquareUpperLimit;
42   uint8               ins_SquareSpeed;
43   uint8               ins_VibratoDelay;
44   uint8               ins_VibratoSpeed;
45   uint8               ins_VibratoDepth;
46   uint8               ins_HardCutRelease;
47   uint8               ins_HardCutReleaseFrames;
48   struct hvl_envelope ins_Envelope;
49   struct hvl_plist    ins_PList;
52 struct hvl_position
54   uint8 pos_Track[MAX_CHANNELS];
55   int8  pos_Transpose[MAX_CHANNELS];
58 struct hvl_step
60   uint8 stp_Note;
61   uint8 stp_Instrument;
62   uint8 stp_FX;
63   uint8 stp_FXParam;
64   uint8 stp_FXb;
65   uint8 stp_FXbParam;
68 struct hvl_voice
70   int16                  vc_Track;
71   int16                  vc_NextTrack;
72   int16                  vc_Transpose;
73   int16                  vc_NextTranspose;
74   int32                  vc_ADSRVolume;
75   struct hvl_envelope    vc_ADSR;
76   struct hvl_instrument *vc_Instrument;
77   uint32                 vc_SamplePos;
78   uint32                 vc_Delta;
79   uint16                 vc_InstrPeriod;
80   uint16                 vc_TrackPeriod;
81   uint16                 vc_VibratoPeriod;
82   uint16                 vc_WaveLength;
83   int16                  vc_NoteMaxVolume;
84   uint16                 vc_PerfSubVolume;
85   uint8                  vc_NewWaveform;
86   uint8                  vc_Waveform;
87   uint8                  vc_PlantPeriod;
88   uint8                  vc_VoiceVolume;
89   uint8                  vc_PlantSquare;
90   uint8                  vc_IgnoreSquare;
91   uint8                  vc_FixedNote;
92   int16                  vc_VolumeSlideUp;
93   int16                  vc_VolumeSlideDown;
94   int16                  vc_HardCut;
95   uint8                  vc_HardCutRelease;
96   int16                  vc_HardCutReleaseF;
97   uint8                  vc_PeriodSlideOn;
98   int16                  vc_PeriodSlideSpeed;
99   int16                  vc_PeriodSlidePeriod;
100   int16                  vc_PeriodSlideLimit;
101   int16                  vc_PeriodSlideWithLimit;
102   int16                  vc_PeriodPerfSlideSpeed;
103   int16                  vc_PeriodPerfSlidePeriod;
104   uint8                  vc_PeriodPerfSlideOn;
105   int16                  vc_VibratoDelay;
106   int16                  vc_VibratoSpeed;
107   int16                  vc_VibratoCurrent;
108   int16                  vc_VibratoDepth;
109   int16                  vc_SquareOn;
110   int16                  vc_SquareInit;
111   int16                  vc_SquareWait;
112   int16                  vc_SquareLowerLimit;
113   int16                  vc_SquareUpperLimit;
114   int16                  vc_SquarePos;
115   int16                  vc_SquareSign;
116   int16                  vc_SquareSlidingIn;
117   int16                  vc_SquareReverse;
118   uint8                  vc_FilterOn;
119   uint8                  vc_FilterInit;
120   int16                  vc_FilterWait;
121   int16                  vc_FilterSpeed;
122   int16                  vc_FilterUpperLimit;
123   int16                  vc_FilterLowerLimit;
124   int16                  vc_FilterPos;
125   int16                  vc_FilterSign;
126   int16                  vc_FilterSlidingIn;
127   int16                  vc_IgnoreFilter;
128   int16                  vc_PerfCurrent;
129   int16                  vc_PerfSpeed;
130   int16                  vc_PerfWait;
131   struct hvl_plist      *vc_PerfList;
132   int8                  *vc_AudioPointer;
133   int8                  *vc_AudioSource;
134   uint8                  vc_NoteDelayOn;
135   uint8                  vc_NoteCutOn;
136   int16                  vc_NoteDelayWait;
137   int16                  vc_NoteCutWait;
138   int16                  vc_AudioPeriod;
139   int16                  vc_AudioVolume;
140   int32                  vc_WNRandom;
141   int8                  *vc_MixSource;
142   int8                   vc_SquareTempBuffer[0x80];
143   int8                   vc_VoiceBuffer[0x282*4];
144   uint8                  vc_VoiceNum;
145   uint8                  vc_TrackMasterVolume;
146   uint8                  vc_TrackOn;
147   int16                  vc_VoicePeriod;
148   uint32                 vc_Pan;
149   uint32                 vc_SetPan;   // New for 1.4
150   uint32                 vc_PanMultLeft;
151   uint32                 vc_PanMultRight;
152   uint32                 vc_RingSamplePos;
153   uint32                 vc_RingDelta;
154   int8                  *vc_RingMixSource;
155   uint8                  vc_RingPlantPeriod;
156   int16                  vc_RingInstrPeriod;
157   int16                  vc_RingBasePeriod;
158   int16                  vc_RingAudioPeriod;
159   int8                  *vc_RingAudioSource;
160   uint8                  vc_RingNewWaveform;
161   uint8                  vc_RingWaveform;
162   uint8                  vc_RingFixedPeriod;
163   int8                   vc_RingVoiceBuffer[0x282*4];
166 struct hvl_tune
168   TEXT                   ht_Name[128];
169   uint16                 ht_SongNum;
170   uint32                 ht_Frequency;
171   float64                ht_FreqF;
172   int8                  *ht_WaveformTab[MAX_CHANNELS];
173   uint16                 ht_Restart;
174   uint16                 ht_PositionNr;
175   uint8                  ht_SpeedMultiplier;
176   uint8                  ht_TrackLength;
177   uint8                  ht_TrackNr;
178   uint8                  ht_InstrumentNr;
179   uint8                  ht_SubsongNr;
180   uint16                 ht_PosJump;
181   uint32                 ht_PlayingTime;
182   int16                  ht_Tempo;
183   int16                  ht_PosNr;
184   int16                  ht_StepWaitFrames;
185   int16                  ht_NoteNr;
186   uint16                 ht_PosJumpNote;
187   uint8                  ht_GetNewPosition;
188   uint8                  ht_PatternBreak;
189   uint8                  ht_SongEndReached;
190   uint8                  ht_Stereo;
191   uint16                *ht_Subsongs;
192   uint16                 ht_Channels;
193   struct hvl_position   *ht_Positions;
194   struct hvl_step        ht_Tracks[256][64];
195   struct hvl_instrument *ht_Instruments;
196   struct hvl_voice       ht_Voices[MAX_CHANNELS];
197   int32                  ht_defstereo;
198   int32                  ht_defpanleft;
199   int32                  ht_defpanright;
200   int32                  ht_mixgain;
203 void hvl_DecodeFrame( struct hvl_tune *ht, int8 *buf1, int8 *buf2, int32 bufmod );
204 void hvl_InitReplayer( void );
205 BOOL hvl_InitSubsong( struct hvl_tune *ht, uint32 nr );
206 struct hvl_tune *hvl_LoadTune( TEXT *name, uint32 freq, uint32 defstereo );
207 void hvl_FreeTune( struct hvl_tune *ht );
209 struct hvl_tune *tune;
211 int play;
212 int plonked;