diff options
Diffstat (limited to 'modules/chibi/cp_player_data.h')
| -rw-r--r-- | modules/chibi/cp_player_data.h | 423 |
1 files changed, 201 insertions, 222 deletions
diff --git a/modules/chibi/cp_player_data.h b/modules/chibi/cp_player_data.h index c59df5f0d..a6ff6c1d1 100644 --- a/modules/chibi/cp_player_data.h +++ b/modules/chibi/cp_player_data.h @@ -31,8 +31,8 @@ #define CP_PLAYER_DATA_H #include "cp_config.h" -#include "cp_song.h" #include "cp_mixer.h" +#include "cp_song.h" #include "cp_tables.h" /**CPPlayer Data @@ -49,46 +49,43 @@ I hope you dont get sick reading this //Default pan values - class CPPlayer { enum { - PAN_SURROUND=512, - PAN_RIGHT=255, - PAN_LEFT=0, - PAN_CENTER=128 + PAN_SURROUND = 512, + PAN_RIGHT = 255, + PAN_LEFT = 0, + PAN_CENTER = 128 }; - CPSong *song; CPMixer *mixer; - struct Filter_Control { + struct Filter_Control { int32_t it_reso; int32_t it_cutoff; int32_t envelope_cutoff; int32_t final_cutoff; - - void process(); - void set_filter_parameters(int *p_cutoff,uint8_t *p_reso); - }; + void process(); + void set_filter_parameters(int *p_cutoff, uint8_t *p_reso); + }; //tells you if a channel is doing //noteoff/notekill/notefade/etc enum { - - END_NOTE_NOTHING=0, - END_NOTE_OFF=1, - END_NOTE_FADE=2, - END_NOTE_KILL=4 + + END_NOTE_NOTHING = 0, + END_NOTE_OFF = 1, + END_NOTE_FADE = 2, + END_NOTE_KILL = 4 }; - + //Tells you what should a channel restart enum { - + KICK_NOTHING, KICK_NOTE, KICK_NOTEOFF, @@ -96,13 +93,13 @@ class CPPlayer { }; enum { - - MAX_VOICES=256 + + MAX_VOICES = 256 }; - + struct Channel_Control; - struct Voice_Control { + struct Voice_Control { struct Envelope_Control { @@ -114,25 +111,24 @@ class CPPlayer { bool terminated; bool active; bool kill; - }; - Filter_Control filter; - uint16_t reverb_send; - uint16_t chorus_send; + Filter_Control filter; + uint16_t reverb_send; + uint16_t chorus_send; - CPInstrument* instrument_ptr; - CPSample* sample_ptr; + CPInstrument *instrument_ptr; + CPSample *sample_ptr; -// Sample_Data *sample_data; + // Sample_Data *sample_data; - int32_t period; + int32_t period; - int32_t sample_start_index; /* The starting byte index in the sample */ + int32_t sample_start_index; /* The starting byte index in the sample */ bool has_master_channel; int master_channel_index; - int instruement_index; + int instruement_index; int instrument_index; int sample_index; @@ -140,27 +136,27 @@ class CPPlayer { int note_end_flags; - uint8_t sample; /* which instrument number */ + uint8_t sample; /* which instrument number */ - int16_t output_volume; /* output volume (vol + sampcol + instvol) */ - int8_t channel_volume; /* channel's "global" volume */ - uint16_t fadeout_volume; /* fading volume rate */ - int32_t total_volume; /* total volume of channel (before global mixings) */ - uint8_t kick; /* if true = sample has to be restarted */ - - uint8_t note; /* the audible note (as heard, direct rep of period) */ + int16_t output_volume; /* output volume (vol + sampcol + instvol) */ + int8_t channel_volume; /* channel's "global" volume */ + uint16_t fadeout_volume; /* fading volume rate */ + int32_t total_volume; /* total volume of channel (before global mixings) */ + uint8_t kick; /* if true = sample has to be restarted */ - int16_t panning; /* panning position */ - - uint8_t nna; /* New note action type + master/slave flags */ - uint8_t volflg; /* volume envelope settings */ - uint8_t panflg; /* panning envelope settings */ - uint8_t pitflg; /* pitch envelope settings */ - uint8_t keyoff; /* if true = fade out and stuff */ - int16_t handle; /* which sample-handle */ - int32_t start; /* The start byte index in the sample */ - - /* Below here is info NOT in MP_CONTROL!! */ + uint8_t note; /* the audible note (as heard, direct rep of period) */ + + int16_t panning; /* panning position */ + + uint8_t nna; /* New note action type + master/slave flags */ + uint8_t volflg; /* volume envelope settings */ + uint8_t panflg; /* panning envelope settings */ + uint8_t pitflg; /* pitch envelope settings */ + uint8_t keyoff; /* if true = fade out and stuff */ + int16_t handle; /* which sample-handle */ + int32_t start; /* The start byte index in the sample */ + + /* Below here is info NOT in MP_CONTROL!! */ //ENVPR venv; //ENVPR penv; //ENVPR cenv; @@ -168,60 +164,56 @@ class CPPlayer { Envelope_Control volume_envelope_ctrl; Envelope_Control panning_envelope_ctrl; Envelope_Control pitch_envelope_ctrl; - - uint16_t auto_vibrato_pos; /* autovibrato pos */ - uint16_t auto_vibrato_sweep_pos; /* autovibrato sweep pos */ - - int16_t masterchn; - uint16_t masterperiod; - - Channel_Control* master_channel; /* index of "master" effects channel */ - void start_envelope(CPEnvelope *p_envelope,Envelope_Control *p_envelope_ctrl,Envelope_Control *p_from_env); - bool process_envelope(CPEnvelope *p_envelope,Envelope_Control *p_envelope_ctrl); + uint16_t auto_vibrato_pos; /* autovibrato pos */ + uint16_t auto_vibrato_sweep_pos; /* autovibrato sweep pos */ + + int16_t masterchn; + uint16_t masterperiod; + + Channel_Control *master_channel; /* index of "master" effects channel */ + + void start_envelope(CPEnvelope *p_envelope, Envelope_Control *p_envelope_ctrl, Envelope_Control *p_from_env); + bool process_envelope(CPEnvelope *p_envelope, Envelope_Control *p_envelope_ctrl); uint16_t display_volume; - + Voice_Control() { - + reset(); } void reset(); - void update_info_from_master_channel(); - - + void update_info_from_master_channel(); }; - struct Channel_Control { /* NOTE info */ - uint8_t note; /* the audible note as heard, direct rep of period */ - uint8_t real_note; /* the note that indexes the audible */ - int32_t sample_start_index; /* The starting byte index in the sample */ - uint8_t old_note; + uint8_t note; /* the audible note as heard, direct rep of period */ + uint8_t real_note; /* the note that indexes the audible */ + int32_t sample_start_index; /* The starting byte index in the sample */ + uint8_t old_note; uint8_t kick; - - Filter_Control filter; - uint16_t reverb_send; - uint16_t chorus_send; - + Filter_Control filter; + uint16_t reverb_send; + uint16_t chorus_send; + int note_end_flags; /* INSTRUMENT INFO */ - CPInstrument* instrument_ptr; - CPSample* sample_ptr; + CPInstrument *instrument_ptr; + CPSample *sample_ptr; - uint8_t instrument_index; - uint8_t sample_index; + uint8_t instrument_index; + uint8_t sample_index; bool new_instrument; /* SAMPLE SPECIFIC INFO */ - int32_t base_speed; /* what finetune to use */ + int32_t base_speed; /* what finetune to use */ /* INSTRUMENT SPECIFIC INFO */ @@ -233,13 +225,13 @@ class CPPlayer { bool panning_envelope_on; bool pitch_envelope_on; - bool has_own_period; + bool has_own_period; bool row_has_note; /* VOLUME COLUMN */ - int16_t volume; /* amiga volume (0 t/m 64) to play the sample at */ + int16_t volume; /* amiga volume (0 t/m 64) to play the sample at */ int16_t aux_volume; bool has_own_volume; bool mute; @@ -247,34 +239,32 @@ class CPPlayer { /* VOLUME/PAN/PITCH MODIFIERS */ - int8_t default_volume; // CHANNEL default volume (0-64) - int16_t channel_volume; // CHANNEL current volume //chanvol - current! - int16_t output_volume; /* output volume (vol + sampcol + instvol) //volume */ - int16_t channel_global_volume; - - uint16_t fadeout_volume; /* fading volume rate */ + int8_t default_volume; // CHANNEL default volume (0-64) + int16_t channel_volume; // CHANNEL current volume //chanvol - current! + int16_t output_volume; /* output volume (vol + sampcol + instvol) //volume */ + int16_t channel_global_volume; - int32_t period; /* period to play the sample at */ - - /* PAN */ + uint16_t fadeout_volume; /* fading volume rate */ - int16_t panning; /* panning position */ - int16_t channel_panning; - int8_t sliding; + int32_t period; /* period to play the sample at */ - uint16_t aux_period; /* temporary period */ + /* PAN */ + int16_t panning; /* panning position */ + int16_t channel_panning; + int8_t sliding; + uint16_t aux_period; /* temporary period */ /* TIMING */ - uint8_t note_delay; /* (used for note delay) */ + uint8_t note_delay; /* (used for note delay) */ /* Slave Voice Control */ - Voice_Control *slave_voice; /* Audio Slave of current effects control channel */ - + Voice_Control *slave_voice; /* Audio Slave of current effects control channel */ + struct Carry { - + Voice_Control::Envelope_Control vol; Voice_Control::Envelope_Control pan; Voice_Control::Envelope_Control pitch; @@ -282,11 +272,9 @@ class CPPlayer { } carry; + uint8_t slave_voice_index; /* Audio Slave of current effects control channel */ - - uint8_t slave_voice_index; /* Audio Slave of current effects control channel */ - - uint8_t* row; /* row currently playing on this channel */ + uint8_t *row; /* row currently playing on this channel */ /* effect memory variables */ @@ -302,65 +290,65 @@ class CPPlayer { int32_t hi_offset; /* Panbrello waveform */ - uint8_t panbrello_type; /* current panbrello waveform */ - uint8_t panbrello_position; /* current panbrello position */ - int8_t panbrello_speed; /* "" speed */ - uint8_t panbrello_depth; /* "" depth */ - uint8_t panbrello_info; - /* Arpegio */ + uint8_t panbrello_type; /* current panbrello waveform */ + uint8_t panbrello_position; /* current panbrello position */ + int8_t panbrello_speed; /* "" speed */ + uint8_t panbrello_depth; /* "" depth */ + uint8_t panbrello_info; + /* Arpegio */ - uint8_t arpegio_info; - /* CPPattern Loop */ + uint8_t arpegio_info; + /* CPPattern Loop */ int pattern_loop_position; int8_t pattern_loop_count; - /* Vibrato */ - bool doing_vibrato; - int8_t vibrato_position; /* current vibrato position */ - uint8_t vibrato_speed; /* "" speed */ - uint8_t vibrato_depth; /* "" depth */ - uint8_t vibrato_type; + /* Vibrato */ + bool doing_vibrato; + int8_t vibrato_position; /* current vibrato position */ + uint8_t vibrato_speed; /* "" speed */ + uint8_t vibrato_depth; /* "" depth */ + uint8_t vibrato_type; /* Tremor */ - int8_t tremor_position; - uint8_t tremor_speed; /* s3m tremor ontime/offtime */ - uint8_t tremor_depth; - uint8_t tremor_info; + int8_t tremor_position; + uint8_t tremor_speed; /* s3m tremor ontime/offtime */ + uint8_t tremor_depth; + uint8_t tremor_info; /* Tremolo */ - int8_t tremolo_position; - uint8_t tremolo_speed; /* s3m tremor ontime/offtime */ - uint8_t tremolo_depth; - uint8_t tremolo_info; - uint8_t tremolo_type; + int8_t tremolo_position; + uint8_t tremolo_speed; /* s3m tremor ontime/offtime */ + uint8_t tremolo_depth; + uint8_t tremolo_info; + uint8_t tremolo_type; /* Retrig */ - int8_t retrig_counter; /* retrig value (0 means don't retrig) */ - uint8_t retrig_speed; /* last used retrig speed */ - uint8_t retrig_volslide; /* last used retrig slide */ + int8_t retrig_counter; /* retrig value (0 means don't retrig) */ + uint8_t retrig_speed; /* last used retrig speed */ + uint8_t retrig_volslide; /* last used retrig slide */ /* CPSample Offset */ - int32_t sample_offset_hi; /* last used high order of sample offset */ - uint16_t sample_offset; /* last used low order of sample-offset (effect 9) */ - uint16_t sample_offset_fine; /* fine sample offset memory */ + int32_t sample_offset_hi; /* last used high order of sample offset */ + uint16_t sample_offset; /* last used low order of sample-offset (effect 9) */ + uint16_t sample_offset_fine; /* fine sample offset memory */ /* Portamento */ uint16_t slide_to_period; /* period to slide to (with effect 3 or 5) */ uint8_t portamento_speed; - /* Volume Slide */ + /* Volume Slide */ uint8_t volume_slide_info; - /* Channel Volume Slide */ + /* Channel Volume Slide */ uint8_t channel_volume_slide_info; - /* Global Volume Slide */ + /* Global Volume Slide */ - uint8_t global_volume_slide_info; + uint8_t global_volume_slide_info; - /* Channel Pan Slide */ + /* Channel Pan Slide */ uint8_t channel_pan_slide_info; @@ -371,30 +359,33 @@ class CPPlayer { uint8_t tempo_slide_info; - /* S effects memory */ + /* S effects memory */ - uint8_t current_S_effect; - uint8_t current_S_data; + uint8_t current_S_effect; + uint8_t current_S_data; /* Volume column memory */ - uint8_t volume_column_effect_mem; - uint8_t volume_column_data_mem; + uint8_t volume_column_effect_mem; + uint8_t volume_column_data_mem; int64_t last_event_usecs; bool reserved; - + void reset(); - Channel_Control() { channel_global_volume=255; last_event_usecs=-1; } + Channel_Control() { + channel_global_volume = 255; + last_event_usecs = -1; + } }; - + struct Control_Variables { // control variables (dynamic version) of initial variables bool reached_end; - + char play_mode; - bool filters; + bool filters; int global_volume; int speed; int tempo; @@ -412,7 +403,7 @@ class CPPlayer { bool force_no_nna; bool external_vibrato; - + struct Position { int current_order; @@ -426,156 +417,144 @@ class CPPlayer { Position position; Position previous_position; - }; - Voice_Control voice[MAX_VOICES]; - + Control_Variables control; /* VOICE SETUP */ - + void setup_voices(); /* MIXER SETUP */ void handle_tick(); void update_mixer(); - + /* NOTE / INSTRUMENT PROCESSING */ - void process_new_note(int p_track,uint8_t p_note); - bool process_new_instrument(int p_track,uint8_t p_instrument); - bool process_note_and_instrument(int p_track,int p_note,int p_instrument); - + void process_new_note(int p_track, uint8_t p_note); + bool process_new_instrument(int p_track, uint8_t p_instrument); + bool process_note_and_instrument(int p_track, int p_note, int p_instrument); + /* EFFECT PROCESSING */ void do_effect_S(int p_track); void do_panbrello(int p_track); void do_global_volume_slide(int p_track); - void do_tremolo(int p_track); - void do_retrig(int p_track); + void do_tremolo(int p_track); + void do_retrig(int p_track); void do_pan_slide(int p_track); - void do_channel_volume_slide(int p_track); - void do_volume_slide(int p_track,int inf); - void do_pitch_slide_down(int p_track,uint8_t inf); - void do_pitch_slide_up(int p_track,uint8_t inf); - void do_tremor(int p_track); - void do_vibrato(int p_track,bool fine); - void do_pitch_slide_to_note(int p_track); - void run_effects(int p_track); - void run_volume_column_effects(int p_track); - void pre_process_effects(); - void do_arpegio(int p_track); + void do_channel_volume_slide(int p_track); + void do_volume_slide(int p_track, int inf); + void do_pitch_slide_down(int p_track, uint8_t inf); + void do_pitch_slide_up(int p_track, uint8_t inf); + void do_tremor(int p_track); + void do_vibrato(int p_track, bool fine); + void do_pitch_slide_to_note(int p_track); + void run_effects(int p_track); + void run_volume_column_effects(int p_track); + void pre_process_effects(); + void do_arpegio(int p_track); uint64_t song_usecs; /* NNA */ void process_NNAs(); - /* MISC UTILS */ - - int find_empty_voice(); - void process_volume_column(int p_track,uint8_t p_volume); - void process_note(int p_track,CPNote p_note); + int find_empty_voice(); + void process_volume_column(int p_track, uint8_t p_volume); + void process_note(int p_track, CPNote p_note); /* CPTables */ - static uint8_t auto_vibrato_table[128]; - static uint8_t vibrato_table[32]; - static int8_t panbrello_table[256]; + static uint8_t auto_vibrato_table[128]; + static uint8_t vibrato_table[32]; + static int8_t panbrello_table[256]; static void callback_function(void *p_userdata); public: - //Play modes + //Play modes enum { - - PLAY_NOTHING =0, - PLAY_PATTERN =1, - PLAY_SONG =2 - }; + PLAY_NOTHING = 0, + PLAY_PATTERN = 1, + PLAY_SONG = 2 + }; - int32_t get_frequency(int32_t period); - int32_t get_period(uint16_t note,int32_t p_c5freq); - + int32_t get_frequency(int32_t period); + int32_t get_period(uint16_t note, int32_t p_c5freq); int get_current_tempo() { return control.tempo; }; int get_current_speed() { return control.speed; }; - int get_voices_used() { return control.voices_used;}; - int get_voice_envelope_pos(int p_voice,CPEnvelope *p_envelope); + int get_voices_used() { return control.voices_used; }; + int get_voice_envelope_pos(int p_voice, CPEnvelope *p_envelope); int get_voice_amount_limit() { return control.max_voices; }; void set_voice_amount_limit(int p_limit); void set_reserved_voices(int p_amount); int get_reserved_voices_amount(); - + bool is_voice_active(int p_voice); int get_channel_voice(int p_channel); - const char* get_voice_sample_name(int p_voice); - const char* get_voice_instrument_name(int p_voice); - CPEnvelope* get_voice_envelope(int p_voice,CPInstrument::EnvelopeType p_env_type); - int get_voice_envelope_pos(int p_voice,CPInstrument::EnvelopeType p_env_type); + const char *get_voice_sample_name(int p_voice); + const char *get_voice_instrument_name(int p_voice); + CPEnvelope *get_voice_envelope(int p_voice, CPInstrument::EnvelopeType p_env_type); + int get_voice_envelope_pos(int p_voice, CPInstrument::EnvelopeType p_env_type); int get_voice_volume(int p_voice); - + int get_voice_sample_index(int p_voice); void set_virtual_channels(int p_amount); int get_virtual_channels() { return control.max_voices; }; - /* Play Info/Position */ - bool is_playing() { return (control.play_mode>0); }; - int get_play_mode() {return (control.play_mode);}; + bool is_playing() { return (control.play_mode > 0); }; + int get_play_mode() { return (control.play_mode); }; int get_current_order() { return control.position.current_order; }; int get_current_row() { return control.position.current_row; }; int get_current_pattern() { return control.position.current_pattern; }; - void goto_next_order(); - void goto_previous_order(); + void goto_next_order(); + void goto_previous_order(); void process_tick(); + CPMixer *get_mixer_ptr() { - CPMixer* get_mixer_ptr() { - - return mixer; + return mixer; } - void reset(); - - /* External player control - editor - */ - void play_start_pattern(int p_pattern); + void play_start_pattern(int p_pattern); void play_start_song(); void play_start_song_from_order(int p_order); - void play_start_song_from_order_and_row(int p_order,int p_row); - void play_start(int p_pattern, int p_order, int p_row,bool p_lock=true); + void play_start_song_from_order_and_row(int p_order, int p_row); + void play_start(int p_pattern, int p_order, int p_row, bool p_lock = true); + + void play_stop(); + void play_note(int p_channel, CPNote note, bool p_reserve = false); - void play_stop(); - void play_note(int p_channel,CPNote note,bool p_reserve=false); + bool reached_end_of_song(); - bool reached_end_of_song(); - - void set_force_no_nna(bool p_force); - void set_force_external_vibratos(bool p_force); + void set_force_no_nna(bool p_force); + void set_force_external_vibratos(bool p_force); - void set_filters_enabled(bool p_enable); - bool are_filters_enabled() { return control.filters; } + void set_filters_enabled(bool p_enable); + bool are_filters_enabled() { return control.filters; } - void set_channel_global_volume(int p_channel,int p_volume); //0-255 + void set_channel_global_volume(int p_channel, int p_volume); //0-255 int get_channel_global_volume(int p_channel) const; int64_t get_channel_last_note_time_usec(int p_channel) const; CPSong *get_song() { return song; }; - - CPPlayer(CPMixer *p_mixer,CPSong *p_song); + CPPlayer(CPMixer *p_mixer, CPSong *p_song); ~CPPlayer(); }; |
