]> git.0d.be Git - jack_mixer.git/commitdiff
Remove bad crackling when changing the volume through MIDI
authorArnout Engelen <arnouten@bzzt.net>
Wed, 5 May 2010 08:18:52 +0000 (10:18 +0200)
committerArnout <arnouten@bzzt.net>
Wed, 5 May 2010 08:22:55 +0000 (10:22 +0200)
From the GUI, the volume only changes at the start of a block.

From JACK MIDI, the volume can also change within a block. jack_mixer then
neatly makes sure the volume change is applied at exactly the right sample
in the buffer.

There was a bug in this code that introduced a bad crackle, which is fixed in
this commit. There's still a small crackle left, but this is another issue,
and also audible when changing the volume through the GUI.

Related to:
- https://gna.org/support/?2533
- https://gna.org/bugs/?15947

jack_mixer.c

index 94a7ec5024c77e23b899535d464e667f62bea3fa..f35f89a9b009d3c517bb7f9427e19a720fe26e9a 100644 (file)
@@ -570,8 +570,7 @@ mix_one(
   jack_default_audio_sample_t frame_right;
   struct channel *mix_channel = (struct channel*)output_mix_channel;
 
-  update_channel_buffers(mix_channel, end-start);
-  for (i = 0; i < (end-start); i++)
+  for (i = start; i < end; i++)
   {
     mix_channel->left_buffer_ptr[i] = 0.0;
     if (mix_channel->stereo)
@@ -859,6 +858,14 @@ process(
     update_channel_buffers(channel_ptr, nframes);
   }
 
+  // Fill output buffers with the input 
+  update_channel_buffers((struct channel*)mixer_ptr->main_mix_channel, nframes);
+  for (node_ptr = mixer_ptr->output_channels_list; node_ptr; node_ptr = g_slist_next(node_ptr))
+  {
+    channel_ptr = node_ptr->data;
+    update_channel_buffers(channel_ptr, nframes);
+  }
+
   offset = 0;
 
 #if defined(HAVE_JACK_MIDI)
@@ -895,6 +902,8 @@ process(
 
       if (in_event.time > offset)
       {
+        // Perform the mixing of the part between the previous volume change
+        // (or the start of the block) up until this one.
         mix(mixer_ptr, offset, in_event.time);
         offset = in_event.time;
       }