[jmsl] Audiosample playback & Synchronization

jmsl at music.columbia.edu jmsl at music.columbia.edu
Mon Jul 12 23:42:19 EDT 2004

Hello Bosun

Unless you need the same sample played at overlapping times, the way you 
are doing is the most efficient.  You can add Synth.FLAG_AUTO_STOP to 
the envelopePort and samplePort queue() calls to shut them down when 
they reach the end.  If you do this you must call start(jsynTimeToPlay) 
on both

There is no single method for stopping a MusicJob at a particular time.  
halt() stops execution immediately.  finish() stops execution after the 
next repeat()

The Usage meter only shows JSyn usage.  I have never seen a case where 
the number of MusicJobs has had any effect on performance.

Currently there is no way to pause a MusicJob

Nick Didkovsky

jmsl at music.columbia.edu wrote:

> Hi Nick. Thanks a lot for all the pointers. They made a big difference.
> I have a couple more questions. I am thinking of doing some 
> optimization of the playback. For example, where I do sample playing,
> --------------------------------------------------------------------------------------------------------------------------------------------------------------- 
> if (sample != null) {
>         int jsynTimeToPlay = (int) 
> JMSL.clock.timeToNative(timeToPlay); //tell component to play at right 
> time?
>         try {
>                 //clear the previous samples out first...
>                 samplePlayer.samplePort.clear(jsynTimeToPlay);
>                 sampleEnvelope.envelopePort.clear(jsynTimeToPlay);
>                 //now play
>                 sampleEnvelope.envelopePort.queue(jsynTimeToPlay, 
> envData);
>                 samplePlayer.samplePort.queue(jsynTimeToPlay, sample);
>                 } catch (SynthException e) {
>                       e.printStackTrace();
>                       return;
>                 }
> }
> --------------------------------------------------------------------------------------------------------------------------------------------------------------- 
> if the same sample is being played repeatedly as will happen in most 
> instances, the playback frequency might not permit the sample to be 
> played to exhaustion. Is it possible in JMSL to pause or stop the 
> samplePlayer (and envelope), reset the sample frame index being played 
> to 0 and restart the samplePlayer? Even more pertinent, would that be 
> a more efficient implementation than simply clearing the samplePlayer 
> every time?
> Can you also give me a clear idea of what the MusicJob halt(), 
> advanceCurrentTime() and finish() methods behave? I could not find any 
> construct for halting (or pausing) an MJ at a specific time. Can a 
> MusicJob be put on hold and restarted?
> Thanks!!!
> -Bosun
> PS does the synth usage include jmsl usage? Since the latter relies on 
> event-scheduling, having a lot of MusicJobs as I did in my testcases 
> might be held responsible.
> At 10:39 PM 7/10/2004, you wrote:
>> Ok sounds like it's working out.
>> I would also comment out the flash and see how things feel when you 
>> move the gui around. Creating new FlashJobs every repeat is not 
>> really an especially bad thing.  Try doing this without calling the 
>> actual flash command and see how things behave.
>> Curious what the speed of your machine is.  Sample playback is very 
>> efficient in JSyn so I wonder what's driving it up to 12%
>> Nick
>> jmsl at music.columbia.edu wrote:
>>> Thanks Nick!!!
>>> On adding the setAdvance, I noticed less GUI interference as per the 
>>> test I mentioned. There was a marked improvement in the output with 
>>> ParallelCollections but only for usages of less than 4%.
>>> The reason I was re-launching each repeat was that I wanted the 
>>> display to hold a flash color for some time, while the sample is 
>>> being played. I have changed it to recreate a FlashJob each repeat 
>>> but I will have to change that to reduce overhead in the full 
>>> application.
>>> Usage shows about 12%. We can consider that an average. My 
>>> application needs to be scalable up to around 40% usage, if 
>>> possible. Thanks again.
>>> - Bosun
> _______________________________________________
> jmsl mailing list
> jmsl at music.columbia.edu
> http://music.columbia.edu/mailman/listinfo/jmsl

More information about the jmsl mailing list