muting individual jack ports on completion

View: New views
6 Messages — Rating Filter:   Alert me  

muting individual jack ports on completion

by Jeremy Hughes-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I've discovered that when playing signals of different length, the jack port
corresponding to the shorter signal is not muted on completion, but keeps
playing from the buffer (in my case this translates to a repeated loop of the
last 0.1 seconds of the signal).

If I understand the code correctly, this happens because in
audioio_jack_manager.cpp, muting is done on a jack-wide basis. If this condition
is false (current->engine_repp->status() != ECA_ENGINE::engine_status_finished),
all jack output ports are muted (line 435 in v2_6_0).

I've poked around a bit, but can't figure out how to do this on a per port
basis. I'd like to contribute a patch (time constraints permitting),
but I need a
few clues as to where to start.

Cheers,

Jeremy
------------------------------------------------------------------------------

_______________________________________________
Ecasound-list mailing list
Ecasound-list@...
https://lists.sourceforge.net/lists/listinfo/ecasound-list

Re: muting individual jack ports on completion

by Julien Claassen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jeremy!
   Can you tell us the ecasound chainsetup you use? I certainly ofen have
sounds, which are of different length, but I have no problem. Maybe this is
due to the fact, that my sounds usually are silent at the end (more than 0.1
secs). But it reminds me of a very old bug years back in my late ALSA and
early JACK days.
   Kindest regards
        Julien

--------
Music was my first love and it will be my last (John Miles)

======== FIND MY WEB-PROJECT AT: ========
http://ltsb.sourceforge.net
the Linux TextBased Studio guide
======= AND MY PERSONAL PAGES AT: =======
http://www.juliencoder.de

------------------------------------------------------------------------------
_______________________________________________
Ecasound-list mailing list
Ecasound-list@...
https://lists.sourceforge.net/lists/listinfo/ecasound-list

Re: muting individual jack ports on completion

by Kai Vehmanen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Thu, 25 Jun 2009, Jeremy Hughes wrote:

> I've discovered that when playing signals of different length, the jack port
> corresponding to the shorter signal is not muted on completion, but keeps
> playing from the buffer (in my case this translates to a repeated loop of the
[...]
> If I understand the code correctly, this happens because in
> audioio_jack_manager.cpp, muting is done on a jack-wide basis. If this condition
[...]
> I've poked around a bit, but can't figure out how to do this on a per port
> basis. I'd like to contribute a patch (time constraints permitting),
> but I need a few clues as to where to start.

hmm, that could indeed happen -- IOW a good catch! At least one way to fix
this is to modify

void AUDIO_IO_JACK_MANAGER::write_samples()

.. so that full 'buffersize_rep' of samples is copied every time
to '(*p)->cb_buffer'. In current code, 'samples' could be zero, in which
case old data could remain in the buffer.

------------------------------------------------------------------------------
_______________________________________________
Ecasound-list mailing list
Ecasound-list@...
https://lists.sourceforge.net/lists/listinfo/ecasound-list

Re: muting individual jack ports on completion

by Jeremy Hughes-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jun 26, 2009 at 9:39 AM, Julien Claassen <julien@...> wrote:
Hi Jeremy!
 Can you tell us the ecasound chainsetup you use? I certainly ofen have sounds, which are of different length, but I have no problem. Maybe this is due to the fact, that my sounds usually are silent at the end (more than 0.1 secs). But it reminds me of a very old bug years back in my late ALSA and early JACK days.
 Kindest regards
      Julien

Apologies, I neglected to include an example. This is the simplest one I could come up with:

   $ ecasound -a:1 -i:foo.wav -o:jack,system -a:2 audioloop,foo.wav -o:jack,system
 


------------------------------------------------------------------------------

_______________________________________________
Ecasound-list mailing list
Ecasound-list@...
https://lists.sourceforge.net/lists/listinfo/ecasound-list

Re: muting individual jack ports on completion

by Jeremy Hughes-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kai,

I've appended a patch to v2_6_0. It works for me so far, but I haven't
tested it vigorously.

On Fri, Jun 26, 2009 at 9:59 AM, Kai Vehmanen <kvehmanen@...> wrote:

>
> Hi,
>
>  [...]
>
> hmm, that could indeed happen -- IOW a good catch! At least one way to fix this is to modify
>
> void AUDIO_IO_JACK_MANAGER::write_samples()
>
> .. so that full 'buffersize_rep' of samples is copied every time
> to '(*p)->cb_buffer'. In current code, 'samples' could be zero, in which case old data could remain in the buffer.


diff --git a/libecasound/plugins/audioio_jack_manager.cpp
b/libecasound/plugins/audioio_jack_manager.cpp
index 0af5846..d6e9b58 100644
--- a/libecasound/plugins/audioio_jack_manager.cpp
+++ b/libecasound/plugins/audioio_jack_manager.cpp
@@ -1621,6 +1621,7 @@ void AUDIO_IO_JACK_MANAGER::write_samples(int
client_id, void* target_buffer, lo
 {
   // DEBUG_CFLOW_STATEMENT(cerr << endl << "write_samples:" << client_id);

+  size_t sample_size = sizeof(jack_default_audio_sample_t);
   long int writesamples = (samples <= buffersize_rep) ? samples :
buffersize_rep;
   jack_default_audio_sample_t* ptr =
     static_cast<jack_default_audio_sample_t*>(target_buffer);
@@ -1629,8 +1630,11 @@ void AUDIO_IO_JACK_MANAGER::write_samples(int
client_id, void* target_buffer, lo
   list<eca_jack_port_data*>::const_iterator p = node->ports.begin();
   while(p != node->ports.end()) {
     if ((*p)->cb_buffer != 0) {
-      memcpy((*p)->cb_buffer, ptr, writesamples *
sizeof(jack_default_audio_sample_t));
+      memcpy((*p)->cb_buffer, ptr, writesamples * sample_size);
       ptr += writesamples;
+      memset((*p)->cb_buffer + (writesamples * sample_size),
+             0,
+             (buffersize_rep - writesamples) * sample_size);
     }
     ++p;
   }

------------------------------------------------------------------------------
_______________________________________________
Ecasound-list mailing list
Ecasound-list@...
https://lists.sourceforge.net/lists/listinfo/ecasound-list

Re: muting individual jack ports on completion

by Kai Vehmanen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Fri, 26 Jun 2009, Jeremy Hughes wrote:

> I've appended a patch to v2_6_0. It works for me so far, but I haven't
> tested it vigorously.

thanks, applied and pushed as git commit:

commit b91de6dcd9665cfcab96fa0bda2938fdd832dca7
Author: Jeremy Hughes <jedahu@...>
Date:   Tue Jun 30 00:54:20 2009 +0300

     Mute individual jack ports on completion

     When streams routed to JACK output ports finished at
     different times, output ports finishing early would get
     stuck producing stale data from previous engine iterations.

  libecasound/plugins/audioio_jack_manager.cpp |    7 +++++--
  1 files changed, 5 insertions(+), 2 deletions(-)

------------------------------------------------------------------------------
_______________________________________________
Ecasound-list mailing list
Ecasound-list@...
https://lists.sourceforge.net/lists/listinfo/ecasound-list