]> git.sesse.net Git - vlc/blobdiff - modules/codec/fluidsynth.c
Use var_InheritString for --decklink-video-connection.
[vlc] / modules / codec / fluidsynth.c
index 5221f8df1d76d89fb81174c6e48b10e8edcbca73..4cf309870a12d496fdf000dd7df4d00e6d9a8038 100644 (file)
 
 #include <fluidsynth.h>
 
+#if (FLUIDSYNTH_VERSION_MAJOR < 1) \
+ || (FLUIDSYNTH_VERSION_MAJOR == 1 && FLUIDSYNTH_VERSION_MINOR < 1)
+# define FLUID_FAILED (-1)
+# define fluid_synth_sysex(synth, ptr, len, d, e, f, g) (FLUID_FAILED)
+# define fluid_synth_system_reset(synth) (FLUID_FAILED)
+# define fluid_synth_channel_pressure(synth, channel, p) (FLUID_FAILED)
+#endif
+
 #define SOUNDFONT_TEXT N_("Sound fonts (required)")
 #define SOUNDFONT_LONGTEXT N_( \
     "A sound fonts file is required for software synthesis." )
@@ -179,11 +187,32 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block)
     if (p_block->i_buffer < 1)
         goto drop;
 
+    uint8_t event = p_block->p_buffer[0];
     uint8_t channel = p_block->p_buffer[0] & 0xf;
+    event &= 0xF0;
+
+    if (event == 0xF0)
+        switch (channel)
+        {
+            case 0:
+                if (p_block->p_buffer[p_block->i_buffer - 1] != 0xF7)
+                {
+            case 7:
+                    msg_Warn (p_dec, "fragmented SysEx not implemented");
+                    goto drop;
+                }
+                fluid_synth_sysex (p_sys->synth, (char *)p_block->p_buffer + 1,
+                                   p_block->i_buffer - 2, NULL, NULL, NULL, 0);
+                break;
+            case 0xF:
+                fluid_synth_system_reset (p_sys->synth);
+                break;
+        }
+
     uint8_t p1 = (p_block->i_buffer > 1) ? (p_block->p_buffer[1] & 0x7f) : 0;
     uint8_t p2 = (p_block->i_buffer > 2) ? (p_block->p_buffer[2] & 0x7f) : 0;
 
-    switch (p_block->p_buffer[0] & 0xf0)
+    switch (event & 0xF0)
     {
         case 0x80:
             fluid_synth_noteoff (p_sys->synth, channel, p1);
@@ -191,14 +220,18 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block)
         case 0x90:
             fluid_synth_noteon (p_sys->synth, channel, p1, p2);
             break;
+        /*case 0xA0: note aftertouch not implemented */
         case 0xB0:
             fluid_synth_cc (p_sys->synth, channel, p1, p2);
             break;
         case 0xC0:
             fluid_synth_program_change (p_sys->synth, channel, p1);
             break;
+        case 0xD0:
+            fluid_synth_channel_pressure (p_sys->synth, channel, p1);
+            break;
         case 0xE0:
-            fluid_synth_pitch_bend (p_sys->synth, channel, (p1 << 7) | p2);
+            fluid_synth_pitch_bend (p_sys->synth, channel, (p2 << 7) | p1);
             break;
     }