5 // SSChannel # to play the music on
8 // maximum possible volume of an org instrument (in the file)
9 // i hear according to orgmaker you can't go higher than F8 but a few
10 // songs actually do go all the way to FF.
11 #define ORG_MAX_VOLUME 255
13 // which panning value is perfectly centered
14 #define ORG_PAN_CENTERED 6
15 #define ORG_PAN_FULL_RIGHT (ORG_PAN_CENTERED + ORG_PAN_CENTERED)
17 #define KEYS_OCTAVE 12
18 #define NUM_NOTES (8 * KEYS_OCTAVE) // range of note values: 00-this.
19 #define NUM_DRUMS 12 // max # of drum instruments to load
21 // if you care to know which music note an org note is, modulus it by
22 // KEYS_OCTAVE and compare to the following constants.
36 #define MAX_SONG_LENGTH 5000 // max song length to allocate for, in notes
39 // this handles the actual synthesis
42 signed short *outbuffer
;
44 // position inside outbuffer (not the same as samples_so_far because org module outputs stereo.
45 // outpos counts data, samples_so_far counts samples. samples_so_far=outpos*2)
46 int outpos
; // incs by 2 for each samples_so_far, one for left ch one for right ch
47 int samples_so_far
; // number of samples generated so far into outbuffer
49 double phaseacc
; // current read position inside wavetable sample
50 double sample_inc
; // speed at which to iterate over the wavetable waveform
53 double master_volume_ratio
, volume_left_ratio
, volume_right_ratio
;
55 int wave
; // index into wavetable (which instrument we're using)
56 int volume
; // last volume value sent to note_gen
57 int panning
; // last panning value sent to note_gen
58 int length
; // # of beats of the current note left to generate
60 int number
; // the chanel number of this channel
66 int beat
; // beat no. that note starts on
67 uchar note
; // 00 - 5F, starts on a C
68 uchar length
; // in beats
69 uchar volume
; // 00 - F8
70 uchar panning
; // 00 - 0C
73 // keeps track of instrument settings for a track
77 int wave
; // which wave (00-99) to use
78 // if pi is set all notes on the channel play for 1024 samples regardless
79 // of length or tempo settings. pi only has meaning on the instrument tracks.
82 int curnote
; // current note (during playback)
83 int loop_note
; // used when looping back to the beginning of a song at beat loop_end
86 stNote note
[MAX_SONG_LENGTH
];
94 int ms_per_beat
, ms_of_last_beat_of_note
;
97 int beats_per_bar
; // == (beats_per_step * steps_per_bar)
99 int samples_per_beat
; // # of samples in each beat
100 int note_closing_samples
; // # of samples of note to generate at the last beat of a note
102 int loop_start
, loop_end
;
104 stInstrument instrument
[16];
110 uint32_t last_fade_time
;