Michael Niedermayer a écrit :
> On Wed, Jul 07, 2010 at 10:50:16PM +0200, Sebastian Vater wrote:
> [...]
>
>   
>> +    /** Player envelope flags. Some sequencers allow envelopes
>> +       to operate in different modes, e.g. different loop types,
>> +       randomization, processing modes which have to be taken
>> +       care specially in the internal playback engine.  */
>> +    int8_t flags;
>> +#define AVSEQ_PLAYER_ENVELOPE_FLAG_FIRST_ADD    0x01 ///< First process 
>> envelope position then get value
>> +#define AVSEQ_PLAYER_ENVELOPE_FLAG_NO_RETRIG    0x02 ///< Do not retrigger 
>> envelope on new note playback
>> +#define AVSEQ_PLAYER_ENVELOPE_FLAG_RANDOM       0x04 ///< Envelope returns 
>> randomized instead of waveform data
>> +#define AVSEQ_PLAYER_ENVELOPE_FLAG_RND_DELAY    0x08 ///< If randomization 
>> is enabled speed is interpreted as delay
>> +#define AVSEQ_PLAYER_ENVELOPE_FLAG_BACKWARDS    0x10 ///< Envelope is 
>> currently being played backwards
>> +#define AVSEQ_PLAYER_ENVELOPE_FLAG_LOOPING      0x20 ///< Envelope is 
>> looping in either sustain or normal mode
>> +#define AVSEQ_PLAYER_ENVELOPE_FLAG_PINGPONG     0x40 ///< Envelope is doing 
>> ping pong style loop
>>     
>
> mostof the flags in your code use signed integers, this seems odd to me
> shouldnt they all be unsigned?
>   

Oh yes...fixed for all header files!

> and most fields are fixed size instead of more common short/int, is that
> intended? 
>   

Yes, large values barely make sense in trackers and changing the
original data size as compared to TuComposer will require intense
testing, which is not possible at current state, I however plan to
change some of the data structures to common int/unsigned at a later
time, when everything works.

Especially player.c has some code in it which only works correctly when
the data type size as it is now. Maybe we can do some of this stuff
during review phase?

Anyway, new player.h patch because I moved the stack pointers from
song.h to here and also the effects lut declaration from player.c to
player.h. Also AVTreeNode's replaced by array pointers.

-- 

Best regards,
                   :-) Basty/CDGS (-:

diff --git a/libavsequencer/player.h b/libavsequencer/player.h
index 48c23b6..c24e9db 100644
--- a/libavsequencer/player.h
+++ b/libavsequencer/player.h
@@ -27,7 +27,80 @@
 #include "libavsequencer/instr.h"
 #include "libavsequencer/sample.h"
 #include "libavsequencer/synth.h"
-#include "libavutil/tree.h"
+
+typedef struct AVSequencerPlayerEffects {
+    /** Function pointer to the actual effect to be executed for this
+       effect. Can be NULL if this effect number is unused. This
+       structure is actually for one effect and there actually
+       pointed as an array with size of number of total effects.  */
+    void (*effect_func)( AVSequencerContext *avctx,
+        AVSequencerPlayerHostChannel *player_host_channel, AVSequencerPlayerChannel *player_channel,
+        uint16_t channel, uint16_t fx_byte, uint16_t data_word );
+
+    /** Function pointer for pre-pattern evaluation. Some effects
+       require a pre-initialization stage. Can be NULL if the effect
+       number either is not used or the effect does not require a
+       pre-initialization stage.  */
+    void (*pre_pattern_func)( AVSequencerContext *avctx,
+        AVSequencerPlayerHostChannel *player_host_channel, AVSequencerPlayerChannel *player_channel,
+        uint16_t channel, uint16_t data_word );
+
+    /** Function pointer for parameter checking for an effect. Can
+       be NULL if the effect number either is not used or the effect
+       does not require pre-checking.  */
+    void (*check_fx_func)( AVSequencerContext *avctx,
+        AVSequencerPlayerHostChannel *player_host_channel, AVSequencerPlayerChannel *player_channel,
+        uint16_t channel, uint16_t *fx_byte, uint16_t *data_word, uint16_t *flags );
+
+    /** Special flags for this effect, this currently defines if the
+       effect is executed during the whole row each tick or just only
+       once per row.  */
+    uint8_t flags;
+#define AVSEQ_PLAYER_EFFECTS_FLAG_EXEC_WHOLE_ROW    0x80 // Effect will be executed during the whole row instead of only once
+
+    /** Logical AND filter mask for the channel control command
+       filtering the affected channel.  */
+    uint8_t and_mask_ctrl;
+
+    /** Standard execution tick when this effect starts to be executed
+       and there is no execute effect command issued which is in most
+       case tick 0 (immediately) or 1 (skip first tick at row).  */
+    uint16_t std_exec_tick;
+} AVSequencerPlayerEffects;
+
+/**
+ * Playback handler hook for allowing developers to execute customized
+ * code in the playback handler under certain conditions. Currently
+ * the hook can either be called once at song end found or each tick,
+ * as well as before execution of the playback handler or after it.
+ * New fields can be added to the end with minor version bumps.
+ * Removal, reordering and changes to existing fields require a major
+ * version bump.
+ */
+typedef struct AVSequencerPlayerHook {
+    /** Special flags for the hook which decide hook call time and
+       purpose.  */
+    int8_t flags;
+#define AVSEQ_PLAYER_HOOK_FLAG_SONG_END    0x01 ///< Hook is only called when song end is being detected instead of each tick
+#define AVSEQ_PLAYER_HOOK_FLAG_BEGINNING   0x02 ///< Hook is called before executing playback code instead of the end
+
+    /** The actual hook function to be called which gets passed the
+       associated AVSequencerContext and the module and sub-song
+       currently processed (i.e. triggered the hook).  */
+    void (*hook_func)( AVSequencerContext *avctx, AVSequencerModule *module,
+                       AVSequencerSong *song, void *hook_data, uint64_t hook_len );
+
+    /** The actual hook data to be passed to the hook function which
+       also gets passed the associated AVSequencerContext and the
+       module and sub-song currently processed (i.e. triggered the
+       hook).  */
+    void *hook_data;
+
+    /** Size of the hook data passed to the hook function which gets
+       passed the associated AVSequencerContext and the module and
+       sub-song currently processed (i.e. triggered the hook).  */
+    uint64_t hook_len;
+} AVSequencerPlayerHook;
 
 /**
  * Player envelope structure used by playback engine for processing
@@ -133,6 +206,15 @@ typedef struct AVSequencerPlayerEnvelope {
  * version bump.
  */
 typedef struct AVSequencerPlayerGlobals {
+    /** Stack pointer for the GoSub command. This stores the
+       return values of the order data and track row for
+       recursive calls.  */
+    uint16_t *gosub_stack;
+
+    /** Stack pointer for the pattern loop command. This stores
+        the loop start and loop count for recursive loops.  */
+    uint16_t *loop_stack;
+
     /** Player envelope flags. Some sequencers allow envelopes
        to operate in different modes, e.g. different loop types,
        randomization, processing modes which have to be taken
@@ -171,13 +253,23 @@ typedef struct AVSequencerPlayerGlobals {
 
     /** Current playing time of the module, in AV_TIME_BASE
        fractional seconds scaled by relative speed.  */
-    uint64_t play_time;
+    uint32_t play_time;
+
+    /** Current playing time fraction of the module, in AV_TIME_BASE
+       fractional seconds scaled by relative speed.  */
+    uint32_t play_time_frac;
 
     /** Current playing ticks of the module, in AV_TIME_BASE
        fractional seconds not scaled by relative speed, i.e.
        you can always determine the exact module position by
        using playing ticks instead of playing time.  */
-    uint64_t play_tics;
+    uint32_t play_tics;
+
+    /** Current playing ticks fraction of the module, in AV_TIME_BASE
+       fractional seconds not scaled by relative speed, i.e.
+       you can always determine the exact module position by
+       using playing ticks instead of playing time.  */
+    uint32_t play_tics_frac;
 
     /** Current final tempo (after done all BpM / SPD calculations)
        in AV_TIME_BASE fractional seconds.  */
@@ -407,7 +499,9 @@ typedef struct AVSequencerPlayerGlobals {
  * Player host channel data structure used by playback engine for
  * processing the host channels which are the channels associated
  * to tracks and the note data is encountered upon. This contains
- * effect memories and all data required for track playback.
+ * effect memories and all data required for track playback. This
+ * structure is actually for one host channel and therefore actually
+ * pointed as an array with size of number of host channels.
  * New fields can be added to the end with minor version bumps.
  * Removal, reordering and changes to existing fields require a major
  * version bump.
@@ -454,7 +548,7 @@ typedef struct AVSequencerPlayerHostChannel {
        can play a simple instrument or sample only or even play a
        single note on a single row if both set instrument and set
        sample bits are set (0x00300000).  */
-    int32_t flags;
+    uint32_t flags;
 #define AVSEQ_PLAYER_HOST_CHANNEL_FLAG_LINEAR_FREQ      0x00000001 ///< Use linear frequency table instead of Amiga
 #define AVSEQ_PLAYER_HOST_CHANNEL_FLAG_BACKWARDS        0x00000002 ///< Playing back track in backwards direction
 #define AVSEQ_PLAYER_HOST_CHANNEL_FLAG_PATTERN_BREAK    0x00000004 ///< Pattern break encountered
@@ -483,7 +577,7 @@ typedef struct AVSequencerPlayerHostChannel {
        about the slide commands, i.e. which direction and invoke state
        to be handled for the playback engine, i.e. execution of the
        actual slides while remaining expected behaviour.  */
-    int32_t fine_slide_flags;
+    uint32_t fine_slide_flags;
 #define AVSEQ_PLAYER_HOST_CHANNEL_FINE_SLIDE_FLAG_FINE_PORTA_DOWN           0x00000001 ///< Fine portamento is directed downwards
 #define AVSEQ_PLAYER_HOST_CHANNEL_FINE_SLIDE_FLAG_PORTA_ONCE_DOWN           0x00000002 ///< Portamento once is directed downwards
 #define AVSEQ_PLAYER_HOST_CHANNEL_FINE_SLIDE_FLAG_FINE_PORTA_ONCE_DOWN      0x00000004 ///< Fine portamento once is directed downwards
@@ -1002,7 +1096,7 @@ typedef struct AVSequencerPlayerHostChannel {
 
     /** Current new transpose value in semitones or 0 if the set
        transpose effect was not used yet during playback.  */
-    uint8_t transpose;
+    int8_t transpose;
 
     /** Current new finetune value in 1/128th of a semitone or 0 if
        the set transpose effect was not used yet during playback.  */
@@ -1028,6 +1122,7 @@ typedef struct AVSequencerPlayerHostChannel {
 #define AVSEQ_PLAYER_HOST_CHANNEL_ENV_CTRL_KIND_SEL_GLOBAL_TREM_ENV 0x0D ///< Global tremolo envelope selected
 #define AVSEQ_PLAYER_HOST_CHANNEL_ENV_CTRL_KIND_SEL_GLOBAL_PAN_ENV  0x0E ///< Global pannolo (panbrello) envelope selected
 #define AVSEQ_PLAYER_HOST_CHANNEL_ENV_CTRL_KIND_SEL_ARPEGGIO_ENV    0x0F ///< Arpeggio definition envelope selected
+#define AVSEQ_PLAYER_HOST_CHANNEL_ENV_CTRL_KIND_SEL_ARPEGGIO_ENV    0x10 ///< Resonance filter envelope selected
 
     /** Current type of envelope to be changed by the envelope control
        command or 0 if the envelope control effect was not used yet
@@ -1139,7 +1234,7 @@ typedef struct AVSequencerPlayerHostChannel {
     /** Current channel control flags which decide how note related
        effects affect volume and panning, etc. and how non-note
        related effects affect pattern loops and breaks, etc.  */
-    int8_t ch_control_flags;
+    uint8_t ch_control_flags;
 #define AVSEQ_PLAYER_HOST_CHANNEL_CH_CONTROL_FLAG_NOTES     0x01   ///< Affect note related effects (volume, panning, etc.)
 #define AVSEQ_PLAYER_HOST_CHANNEL_CH_CONTROL_FLAG_NON_NOTES 0x02   ///< Affect non-note related effects (pattern loops and breaks, etc.)
 
@@ -1256,6 +1351,10 @@ typedef struct AVSequencerPlayerHostChannel {
        envelope.  */
     AVSequencerEnvelope *prev_slide_env;
 
+    /** Pointer to the previous envelope data interpreted as resonance
+       filter control or NULL if there was no previous envelope.  */
+    AVSequencerEnvelope *prev_resonance_env;
+
     /** Pointer to the previous auto vibrato envelope which was
        played by this host channel or NULL if there was no previous
        envelope.  */
@@ -1271,143 +1370,57 @@ typedef struct AVSequencerPlayerHostChannel {
        no previous envelope.  */
     AVSequencerEnvelope *prev_auto_pan_env;
 
-    /** Integer indexed tree root of attached waveforms used
-       by this host channel with AVTreeNode->elem of type
-       AVSequencerSynthWave.  */
-    AVTreeNode *waveform_list;
+    /** Array of pointers containing attached waveforms used by this
+       host channel.  */
+    AVSequencerSynthWave **waveform_list;
 
     /** Pointer to player synth sound definition for the
        current host channel for obtaining the synth
        sound code.  */
     AVSequencerSynth *synth;
 
-    /** Current entry position (line number) of volume handling code
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t volume_pos;
-
-    /** Current entry position (line number) of panning handling code
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t panning_pos;
-
-    /** Current entry position (line number) of slide handling code
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t slide_pos;
-
-    /** Current entry position (line number) of special handling code
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t special_pos;
+    /** Number of attached waveforms used by this host channel.  */
+    uint16_t waveforms;
 
-    /** Current entry position (line number) of sustain volume
-       handling code. This will position jump the code to the target
-       line number of a key off note is pressed or 0 if the current
-       sample does not use synth sound.  */
-    uint16_t volume_sus_pos;
-
-    /** Current entry position (line number) of sustain panning
-       handling code. This will position jump the code to the target
-       line number of a key off note is pressed or 0 if the current
-       sample does not use synth sound.  */
-    uint16_t panning_sus_pos;
-
-    /** Current entry position (line number) of sustain slide
-       handling code. This will position jump the code to the target
-       line number of a key off note is pressed or 0 if the current
-       sample does not use synth sound.  */
-    uint16_t slide_sus_pos;
-
-    /** Current entry position (line number) of sustain special
-       handling code. This will position jump the code to the target
-       line number of a key off note is pressed or 0 if the current
-       sample does not use synth sound.  */
-    uint16_t special_sus_pos;
-
-    /** Current entry position (line number) of volume handling code
-       when NNA has been triggered. This allows a complete custom new
-       note action to be defined or 0 if the current sample does not
-       use synth sound.  */
-    uint16_t vol_nna_pos;
+    /** Current entry position (line number) of volume [0], panning
+       [1], slide [2] and special [3] handling code or 0 if the
+       current sample does not use synth sound.  */
+    uint16_t entry_pos[4];
 
-    /** Current entry position (line number) of panning handling code
-       when NNA has been triggered. This allows a complete custom new
-       note action to be defined or 0 if the current sample does not
-       use synth sound.  */
-    uint16_t pan_nna_pos;
+    /** Current sustain entry position (line number) of volume [0],
+       panning [1], slide [2] and special [3] handling code. This will
+       position jump the code to the target line number of a key off
+       note is pressed or 0 if the current sample does not use synth
+       sound.  */
+    uint16_t sustain_pos[4];
 
-    /** Current entry position (line number) of slide handling code
-       when NNA has been triggered. This allows a complete custom new
-       note action to be defined or 0 if the current sample does not
-       use synth sound.  */
-    uint16_t slide_nna_pos;
+    /** Current entry position (line number) of volume [0], panning
+       [1], slide [2] and special [3] handling code when NNA has been
+       triggered. This allows a complete custom new note action to be
+       defined or 0 if the current sample does not use synth
+       sound.  */
+    uint16_t nna_pos[4];
 
-    /** Current entry position (line number) of special handling code
-       when NNA has been triggered. This allows a complete custom new
-       note action to be defined or 0 if the current sample does not
-       use synth sound.  */
-    uint16_t special_nna_pos;
-
-    /** Current entry position (line number) of volume handling code
-       when DNA has been triggered. This allows a complete custom
-       duplicate note action to be defined or 0 if the current sample
-       does not use synth sound.  */
-    uint16_t vol_dna_pos;
-
-    /** Current entry position (line number) of panning handling code
-       when DNA has been triggered. This allows a complete custom
-       duplicate note action to be defined or 0 if the current sample
-       does not use synth sound.  */
-    uint16_t pan_dna_pos;
-
-    /** Current entry position (line number) of slide handling code
-       when DNA has been triggered. This allows a complete custom
-       duplicate note action to be defined or 0 if the current sample
-       does not use synth sound.  */
-    uint16_t slide_dna_pos;
-
-    /** Current entry position (line number) of special handling code
-       when DNA has been triggered. This allows a complete custom
-       duplicate note action to be defined or 0 if the current sample
-       does not use synth sound.  */
-    uint16_t special_dna_pos;
+    /** Current entry position (line number) of volume [0], panning
+       [1], slide [2] and special [3] handling code when DNA has been
+       triggered. This allows a complete custom duplicate note action
+       to be defined or 0 if the current sample does not use synth
+       sound.  */
+    uint16_t dna_pos[4];
 
     /** Initial contents of the 16 variable registers (v0-v15) or 0
        if the current sample does not use synth sound.  */
     uint16_t variable[16];
 
-    /** Current status of volume variable condition status register
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t vol_cond_var;
-#define AVSEQ_PLAYER_HOST_CHANNEL_VOL_COND_VAR_CARRY       0x01 ///< Carry (C) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_VOL_COND_VAR_OVERFLOW    0x02 ///< Overflow (V) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_VOL_COND_VAR_ZERO        0x04 ///< Zero (Z) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_VOL_COND_VAR_NEGATIVE    0x08 ///< Negative (N) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_VOL_COND_VAR_EXTEND      0x10 ///< Extend (X) bit for volume condition variable
-
-    /** Current status of panning variable condition status register
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t pan_cond_var;
-#define AVSEQ_PLAYER_HOST_CHANNEL_PAN_COND_VAR_CARRY       0x01 ///< Carry (C) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_PAN_COND_VAR_OVERFLOW    0x02 ///< Overflow (V) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_PAN_COND_VAR_ZERO        0x04 ///< Zero (Z) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_PAN_COND_VAR_NEGATIVE    0x08 ///< Negative (N) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_PAN_COND_VAR_EXTEND      0x10 ///< Extend (X) bit for volume condition variable
-
-    /** Current status of slide variable condition status register
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t slide_cond_var;
-#define AVSEQ_PLAYER_HOST_CHANNEL_SLD_COND_VAR_CARRY       0x01 ///< Carry (C) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_SLD_COND_VAR_OVERFLOW    0x02 ///< Overflow (V) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_SLD_COND_VAR_ZERO        0x04 ///< Zero (Z) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_SLD_COND_VAR_NEGATIVE    0x08 ///< Negative (N) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_SLD_COND_VAR_EXTEND      0x10 ///< Extend (X) bit for volume condition variable
-
-    /** Current status of special variable condition status register
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t special_cond_var;
-#define AVSEQ_PLAYER_HOST_CHANNEL_SPC_COND_VAR_CARRY       0x01 ///< Carry (C) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_SPC_COND_VAR_OVERFLOW    0x02 ///< Overflow (V) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_SPC_COND_VAR_ZERO        0x04 ///< Zero (Z) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_SPC_COND_VAR_NEGATIVE    0x08 ///< Negative (N) bit for volume condition variable
-#define AVSEQ_PLAYER_HOST_CHANNEL_SPC_COND_VAR_EXTEND      0x10 ///< Extend (X) bit for volume condition variable
+    /** Current status of volume [0], panning [1], slide [2] and slide
+       [3] variable condition status register or 0 if the current
+       sample does not use synth sound.  */
+    uint16_t cond_var[4];
+#define AVSEQ_PLAYER_HOST_CHANNEL_COND_VAR_CARRY       0x01 ///< Carry (C) bit for condition variable
+#define AVSEQ_PLAYER_HOST_CHANNEL_COND_VAR_OVERFLOW    0x02 ///< Overflow (V) bit for condition variable
+#define AVSEQ_PLAYER_HOST_CHANNEL_COND_VAR_ZERO        0x04 ///< Zero (Z) bit for condition variable
+#define AVSEQ_PLAYER_HOST_CHANNEL_COND_VAR_NEGATIVE    0x08 ///< Negative (N) bit for condition variable
+#define AVSEQ_PLAYER_HOST_CHANNEL_COND_VAR_EXTEND      0x10 ///< Extend (X) bit for condition variable
 
     /** Bit numbers for the controlled channels from 0-255 where the
        first byte determines channel numbers 0-7, the second byte 8-15
@@ -1427,7 +1440,10 @@ typedef struct AVSequencerPlayerHostChannel {
  * channels associated by the tracks taking the new note actions
  * (NNAs) into account so one host channel can have none to multiple
  * virtual channels. This also contains the synth sound processing
- * stuff since these operate mostly on virtual channels.
+ * stuff since these operate mostly on virtual channels. This
+ * structure is actually for one virtual channel and therefore
+ * actually pointed as an array with size of number of virtual
+ * channels.
  * New fields can be added to the end with minor version bumps.
  * Removal, reordering and changes to existing fields require a major
  * version bump.
@@ -1528,7 +1544,7 @@ typedef struct AVSequencerPlayerChannel {
        about the current virtual channel based upon the host channel
        which allocated this virtual channel. The virtual channels are
        allocated according to the new note action (NNA) mechanism.  */
-    int16_t flags;
+    uint16_t flags;
 #define AVSEQ_PLAYER_CHANNEL_FLAG_SUSTAIN               0x0001 ///< Sustain triggered, i.e. release sustain loop points
 #define AVSEQ_PLAYER_CHANNEL_FLAG_FADING                0x0002 ///< Current virtual channel is fading out
 #define AVSEQ_PLAYER_CHANNEL_FLAG_DECAY                 0x0004 ///< Note decay action is running
@@ -1554,6 +1570,10 @@ typedef struct AVSequencerPlayerChannel {
        channel.  */
     AVSequencerPlayerEnvelope slide_env;
 
+    /** Pointer to player envelope data interpreted as resonance
+       filter for the current virtual channel.  */
+    AVSequencerPlayerEnvelope resonance_env;
+
     /** Current player auto vibrato envelope for the current
        virtual channel.  */
     AVSequencerPlayerEnvelope auto_vib_env;
@@ -1661,10 +1681,9 @@ typedef struct AVSequencerPlayerChannel {
        octave * 12 + current note where C-0 equals to one.  */
     uint8_t sample_note;
 
-    /** Integer indexed tree root of attached waveforms used
-       by this virtual channel with AVTreeNode->elem of type
-       AVSequencerSynthWave.  */
-    AVTreeNode *waveform_list;
+    /** Array of pointers containing attached waveforms used by this
+       virtual channel.  */
+    AVSequencerSynthWave **waveform_list;
 
     /** Pointer to sequencer sample synth sound currently being played
        by this virtual channel for obtaining the synth sound code.  */
@@ -1690,136 +1709,51 @@ typedef struct AVSequencerPlayerChannel {
        sound currently being played by this virtual channel.  */
     AVSequencerPlayerSynthWave *arpeggio_waveform;
 
-    /** Current entry position (line number) of volume handling code
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t volume_pos;
-
-    /** Current entry position (line number) of panning handling code
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t panning_pos;
-
-    /** Current entry position (line number) of slide handling code
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t slide_pos;
-
-    /** Current entry position (line number) of special handling code
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t special_pos;
-
-    /** Current entry position (line number) of sustain volume
-       handling code. This will position jump the code to the target
-       line number of a key off note is pressed or 0 if the current
-       sample does not use synth sound.  */
-    uint16_t volume_sus_pos;
-
-    /** Current entry position (line number) of sustain panning
-       handling code. This will position jump the code to the target
-       line number of a key off note is pressed or 0 if the current
-       sample does not use synth sound.  */
-    uint16_t panning_sus_pos;
-
-    /** Current entry position (line number) of sustain slide
-       handling code. This will position jump the code to the target
-       line number of a key off note is pressed or 0 if the current
-       sample does not use synth sound.  */
-    uint16_t slide_sus_pos;
-
-    /** Current entry position (line number) of sustain special
-       handling code. This will position jump the code to the target
-       line number of a key off note is pressed or 0 if the current
-       sample does not use synth sound.  */
-    uint16_t special_sus_pos;
+    /** Number of attached waveforms used by this virtual channel.  */
+    uint16_t waveforms;
 
-    /** Current entry position (line number) of volume handling code
-       when NNA has been triggered. This allows a complete custom new
-       note action to be defined or 0 if the current sample does not
-       use synth sound.  */
-    uint16_t vol_nna_pos;
+    /** Current entry position (line number) of volume [0], panning
+       [1], slide [2] and special [3] handling code or 0 if the
+       current sample does not use synth sound.  */
+    uint16_t entry_pos[4];
 
-    /** Current entry position (line number) of panning handling code
-       when NNA has been triggered. This allows a complete custom new
-       note action to be defined or 0 if the current sample does not
-       use synth sound.  */
-    uint16_t pan_nna_pos;
+    /** Current sustain entry position (line number) of volume [0],
+       panning [1], slide [2] and special [3] handling code. This will
+       position jump the code to the target line number of a key off
+       note is pressed or 0 if the current sample does not use synth
+       sound.  */
+    uint16_t sustain_pos[4];
 
-    /** Current entry position (line number) of slide handling code
-       when NNA has been triggered. This allows a complete custom new
-       note action to be defined or 0 if the current sample does not
-       use synth sound.  */
-    uint16_t slide_nna_pos;
+    /** Current entry position (line number) of volume [0], panning
+       [1], slide [2] and special [3] handling code when NNA has been
+       triggered. This allows a complete custom new note action to be
+       defined or 0 if the current sample does not use synth
+       sound.  */
+    uint16_t nna_pos[4];
 
-    /** Current entry position (line number) of special handling code
-       when NNA has been triggered. This allows a complete custom new
-       note action to be defined or 0 if the current sample does not
-       use synth sound.  */
-    uint16_t special_nna_pos;
-
-    /** Current entry position (line number) of volume handling code
-       when DNA has been triggered. This allows a complete custom
-       duplicate note action to be defined or 0 if the current sample
-       does not use synth sound.  */
-    uint16_t vol_dna_pos;
-
-    /** Current entry position (line number) of panning handling code
-       when DNA has been triggered. This allows a complete custom
-       duplicate note action to be defined or 0 if the current sample
-       does not use synth sound.  */
-    uint16_t pan_dna_pos;
-
-    /** Current entry position (line number) of slide handling code
-       when DNA has been triggered. This allows a complete custom
-       duplicate note action to be defined or 0 if the current sample
-       does not use synth sound.  */
-    uint16_t slide_dna_pos;
-
-    /** Current entry position (line number) of special handling code
-       when DNA has been triggered. This allows a complete custom
-       duplicate note action to be defined or 0 if the current sample
-       does not use synth sound.  */
-    uint16_t special_dna_pos;
+    /** Current entry position (line number) of volume [0], panning
+       [1], slide [2] and special [3] handling code when DNA has been
+       triggered. This allows a complete custom duplicate note action
+       to be defined or 0 if the current sample does not use synth
+       sound.  */
+    uint16_t dna_pos[4];
 
     /** Current contents of the 16 variable registers (v0-v15).  */
     uint16_t variable[16];
 
-    /** Current status of volume variable condition status register
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t vol_cond_var;
-#define AVSEQ_PLAYER_CHANNEL_VOL_COND_VAR_CARRY    0x01 ///< Carry (C) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_VOL_COND_VAR_OVERFLOW 0x02 ///< Overflow (V) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_VOL_COND_VAR_ZERO     0x04 ///< Zero (Z) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_VOL_COND_VAR_NEGATIVE 0x08 ///< Negative (N) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_VOL_COND_VAR_EXTEND   0x10 ///< Extend (X) bit for volume condition variable
-
-    /** Current status of panning variable condition status register
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t pan_cond_var;
-#define AVSEQ_PLAYER_CHANNEL_PAN_COND_VAR_CARRY    0x01 ///< Carry (C) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_PAN_COND_VAR_OVERFLOW 0x02 ///< Overflow (V) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_PAN_COND_VAR_ZERO     0x04 ///< Zero (Z) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_PAN_COND_VAR_NEGATIVE 0x08 ///< Negative (N) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_PAN_COND_VAR_EXTEND   0x10 ///< Extend (X) bit for volume condition variable
-
-    /** Current status of slide variable condition status register
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t slide_cond_var;
-#define AVSEQ_PLAYER_CHANNEL_SLD_COND_VAR_CARRY    0x01 ///< Carry (C) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_SLD_COND_VAR_OVERFLOW 0x02 ///< Overflow (V) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_SLD_COND_VAR_ZERO     0x04 ///< Zero (Z) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_SLD_COND_VAR_NEGATIVE 0x08 ///< Negative (N) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_SLD_COND_VAR_EXTEND   0x10 ///< Extend (X) bit for volume condition variable
-
-    /** Current status of special variable condition status register
-       or 0 if the current sample does not use synth sound.  */
-    uint16_t special_cond_var;
-#define AVSEQ_PLAYER_CHANNEL_SPC_COND_VAR_CARRY    0x01 ///< Carry (C) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_SPC_COND_VAR_OVERFLOW 0x02 ///< Overflow (V) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_SPC_COND_VAR_ZERO     0x04 ///< Zero (Z) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_SPC_COND_VAR_NEGATIVE 0x08 ///< Negative (N) bit for volume condition variable
-#define AVSEQ_PLAYER_CHANNEL_SPC_COND_VAR_EXTEND   0x10 ///< Extend (X) bit for volume condition variable
+    /** Current status of volume [0], panning [1], slide [2] and
+       special [3] variable condition status register or 0 if the
+       current sample does not use synth sound.  */
+    uint16_t cond_var[4];
+#define AVSEQ_PLAYER_CHANNEL_COND_VAR_CARRY    0x01 ///< Carry (C) bit for volume condition variable
+#define AVSEQ_PLAYER_CHANNEL_COND_VAR_OVERFLOW 0x02 ///< Overflow (V) bit for volume condition variable
+#define AVSEQ_PLAYER_CHANNEL_COND_VAR_ZERO     0x04 ///< Zero (Z) bit for volume condition variable
+#define AVSEQ_PLAYER_CHANNEL_COND_VAR_NEGATIVE 0x08 ///< Negative (N) bit for volume condition variable
+#define AVSEQ_PLAYER_CHANNEL_COND_VAR_EXTEND   0x10 ///< Extend (X) bit for volume condition variable
 
     /** Current usage of NNA trigger entry fields. This will run
        custom synth sound code execution on a NNA trigger.  */
-    int8_t use_nna_flags;
+    uint8_t use_nna_flags;
 #define AVSEQ_PLAYER_CHANNEL_USE_NNA_FLAGS_VOLUME_NNA  0x01 ///< Use NNA trigger entry field for volume
 #define AVSEQ_PLAYER_CHANNEL_USE_NNA_FLAGS_PANNING_NNA 0x02 ///< Use NNA trigger entry field for panning
 #define AVSEQ_PLAYER_CHANNEL_USE_NNA_FLAGS_SLIDE_NNA   0x04 ///< Use NNA trigger entry field for slide
@@ -1831,7 +1765,7 @@ typedef struct AVSequencerPlayerChannel {
 
     /** Current usage of sustain entry position fields. This will run
        custom synth sound code execution on a note off trigger.  */
-    int8_t use_sustain_flags;
+    uint8_t use_sustain_flags;
 #define AVSEQ_PLAYER_CHANNEL_USE_SUSTAIN_FLAGS_VOLUME          0x01 ///< Use sustain entry position field for volume
 #define AVSEQ_PLAYER_CHANNEL_USE_SUSTAIN_FLAGS_PANNING         0x02 ///< Use sustain entry position field for panning
 #define AVSEQ_PLAYER_CHANNEL_USE_SUSTAIN_FLAGS_SLIDE           0x04 ///< Use sustain entry position field for slide
@@ -1876,87 +1810,33 @@ typedef struct AVSequencerPlayerChannel {
     /** Current player channel synth sound flags. The indicate certain
        status flags for some synth code instructions. Currently they
        are only defined for the KILL instruction.  */
-    int16_t synth_flags;
+    uint16_t synth_flags;
 #define AVSEQ_PLAYER_CHANNEL_SYNTH_FLAG_KILL_VOLUME    0x01 ///< Volume handling code is running KILL
 #define AVSEQ_PLAYER_CHANNEL_SYNTH_FLAG_KILL_PANNING   0x02 ///< Panning handling code is running KILL
 #define AVSEQ_PLAYER_CHANNEL_SYNTH_FLAG_KILL_SLIDE     0x04 ///< Slide handling code is running KILL
 #define AVSEQ_PLAYER_CHANNEL_SYNTH_FLAG_KILL_SPECIAL   0x08 ///< Special handling code is running KILL
 
-    /** Current volume KILL count in number of ticks or 0 if the
-       current sample does not use synth sound.  */
-    uint16_t kill_vol_count;
-
-    /** Current panning KILL count in number of ticks or 0 if the
-       current sample does not use synth sound.  */
-    uint16_t kill_pan_count;
+    /** Current volume [0], panning [1], slide [2] and special [3]
+       KILL count in number of ticks or 0 if the current sample does
+       not use synth sound.  */
+    uint16_t kill_count[4];
 
-    /** Current slide KILL count in number of ticks or 0 if the
-       current sample does not use synth sound.  */
-    uint16_t kill_sld_count;
+    /** Current volume [0], panning [1], slide [2] and special [3]
+       WAIT count in number of ticks or 0 if the current sample does
+       not use synth sound.  */
+    uint16_t wait_count[4];
 
-    /** Current special KILL count in number of ticks or 0 if the
-       current sample does not use synth sound.  */
-    uint16_t kill_spc_count;
-
-    /** Current volume WAIT count in number of ticks or 0 if the
-       current sample does not use synth sound.  */
-    uint16_t wait_vol_count;
-
-    /** Current panning WAIT count in number of ticks or 0 if the
-       current sample does not use synth sound.  */
-    uint16_t wait_pan_count;
-
-    /** Current slide WAIT count in number of ticks or 0 if the
-       current sample does not use synth sound.  */
-    uint16_t wait_sld_count;
-
-    /** Current special WAIT count in number of ticks or 0 if the
-       current sample does not use synth sound.  */
-    uint16_t wait_spc_count;
-
-    /** Current volume WAIT line number to be reached to continue
-       execution or 0 if the current sample does not use synth
-       sound.  */
-    uint16_t wait_vol_line;
-
-    /** Current panning WAIT line number to be reached to continue
-       execution or 0 if the current sample does not use synth
-       sound.  */
-    uint16_t wait_pan_line;
-
-    /** Current slide WAIT line number to be reached to continue
-       execution or 0 if the current sample does not use synth
-       sound.  */
-    uint16_t wait_sld_line;
-
-    /** Current special WAIT line number to be reached to continue
-       execution or 0 if the current sample does not use synth
-       sound.  */
-    uint16_t wait_spc_line;
-
-    /** Current volume WAIT type (0 is WAITVOL, 1 is WAITPAN, 2 is
-       WAITSLD and 3 is WAITSPC) which has to reach the specified
-       target line number before to continue execution or 0 if the
-       current sample does not use synth sound.  */
-    uint8_t wait_vol_type;
-
-    /** Current panning WAIT type (0 is WAITVOL, 1 is WAITPAN, 2 is
-       WAITSLD and 3 is WAITSPC) which has to reach the specified
-       target line number before to continue execution or 0 if the
-       current sample does not use synth sound.  */
-    uint8_t wait_pan_type;
+    /** Current volume [0], panning [1], slide [2] and special [3]
+       WAIT line number to be reached to continue execution or 0 if
+       the current sample does not use synth sound.  */
+    uint16_t wait_line[4];
 
-    /** Current slide WAIT type (0 is WAITVOL, 1 is WAITPAN, 2 is
-       WAITSLD and 3 is WAITSPC) which has to reach the specified
-       target line number before to continue execution or 0 if the
-       current sample does not use synth sound.  */
-    uint8_t wait_sld_type;
-
-    /** Current special WAIT type (0 is WAITVOL, 1 is WAITPAN, 2 is
-       WAITSLD and 3 is WAITSPC) which has to reach the specified
-       target line number before to continue execution or 0 if the
-       current sample does not use synth sound.  */
-    uint8_t wait_spc_type;
+    /** Current volume [0], panning [1], slide [2] and special [3]
+       WAIT type (0 is WAITVOL, 1 is WAITPAN, 2 is WAITSLD and 3 is
+       WAITSPC) which has to reach the specified target line number
+       before to continue execution or 0 if the current sample does
+       not use synth sound.  */
+    uint8_t wait_type[4];
 
     /** Current PORTAUP synth sound instruction memory or 0 if the
        current sample does not use synth sound.  */
@@ -2047,4 +1927,20 @@ typedef struct AVSequencerPlayerChannel {
     uint16_t pannolo_rate;
 } AVSequencerPlayerChannel;
 
+/**
+ * Executes one tick of the playback handler, calculating everything
+ * needed for the next step of the mixer. This function usually is
+ * called from the mixing engines when they processed all channel data
+ * and need to run the next tick of playback to further full their
+ * output buffers. This function might also be called from a hardware
+ * and/or software interrupts on some platforms.
+ *
+ * @param avctx the AVSequencerContext of which to process the next tick
+ *
+ * @note This is part of the new sequencer API which is still under construction.
+ *       Thus do not use this yet. It may change at any time, do not expect
+ *       ABI compatibility yet!
+ */
+void avseq_playback_handler ( AVSequencerContext *avctx );
+
 #endif /* AVSEQUENCER_PLAYER_H */
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to