Using a SampleQueueOutputStream with variable rate sample reader.

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

Using a SampleQueueOutputStream with variable rate sample reader.

by marmadoc :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

Does anyone know whether it is possible to connect a SampleQueueOutputStream to the sample port of a sample reader having a different frame rate?

The problem I'm experiencing is that the SampleQueueOutputStream seems to supply samples to the sample reader (SampleReader16V1) at an audio rate of 44100 while the rate on the sample reader is set to 24000.  This obviously causes glitches in the resulting audio signal.

Is there another way of doing this, apart from handling the correct timing and queueing of samples myself?

Or am I totally missing something?

Thanks,
Etienne.

Re: Using a SampleQueueOutputStream with variable rate sample reader.

by marmadoc :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK, I found what the problem was: it all still boils down to a timing issue.

marmadoc wrote:
Does anyone know whether it is possible to connect a SampleQueueOutputStream to the sample port of a sample reader having a different frame rate?
Yes, this is possible, and it works.  However, this brings me to my actual problem.

Processing non-real-time is not a problem when all the inputs originate inside the synthEngine, but how should it be handled for example when writing to the said SampleQueueOutputStream from a file.

Reading from the file is slower than the possible processing speed, which results in buffer underruns.

So my question: Is there a way (and if so, how) to control the speed of the synthEngine while processing in non real-time (or at least to let it wait for slower inputs)?

Thanks,
Etienne.




Re: Using a SampleQueueOutputStream with variable rate sample reader.

by music.columbia.edu - JSyn mailing list :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Reading from the file is slower than the possible processing speed,
> which results in buffer underruns.

It should not be so slow. Make sure you use a BufferedInputStream or it
will be very very slow.

> So my question: Is there a way (and if so, how) to control the speed
> of the synthEngine while processing in non real-time (or at least to
> let it wait for slower inputs)?

You can also run the SynthEngine in non real-time by passing
Synth.FLAG_NON_REAL_TIME when you start the engine. When you call
Synth.sleepUntilTick() then the synth engine will generate audio up to
that tick. This works with multiple threads.  You should be able to do
file I/O and other slow stuff in the middle.

Thank you,
Phil Burk
---------------------------------------
SoftSynth, Audio Research and Development
http://www.softsynth.com/
75 Pleasant Lane, San Rafael, CA, 94901 USA
Phone/FAX: 1-415-453-4320
---------------------------------------
_______________________________________________
JSyn mailing list
JSyn@...
To change digest mode or to make other administrative changes visit:
http://music.columbia.edu/mailman/listinfo/jsyn

Re: Using a SampleQueueOutputStream with variable rate sample reader.

by marmadoc :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


music.columbia.edu - JSyn mailing list wrote:
You can also run the SynthEngine in non real-time by passing
Synth.FLAG_NON_REAL_TIME when you start the engine. When you call
Synth.sleepUntilTick() then the synth engine will generate audio up to
that tick. This works with multiple threads.  You should be able to do
file I/O and other slow stuff in the middle.
I do start the engine in NON_REAL_TIME, and use sleepUntilTick(), but what happens if the engine gets to the tick the thread is sleeping until, and the required amount of data has not yet been prepared for queueing?

In other words, what happens if I call sleepUntilTick(x), while tick x has already gone past?  Won't this result in unpredictable data going through the units? This seems to be the problem I'm experiencing probably because of the time it takes to prepare the data.

Thanks again!
Etienne.

Re: Using a SampleQueueOutputStream with variable rate sample reader.

by music.columbia.edu - JSyn mailing list :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 > In other words, what happens if I call sleepUntilTick(x),
 > while tick x has already gone past?

The JSyn clock will not advance until you call sleepUntilTick(x). So
just make sure you have all your other data before you call it. That is
one reason for the non-real-time mode.

Thank you,
Phil Burk
---------------------------------------
SoftSynth, Audio Research and Development
http://www.softsynth.com/
75 Pleasant Lane, San Rafael, CA, 94901 USA
Phone/FAX: 1-415-453-4320
---------------------------------------

_______________________________________________
JSyn mailing list
JSyn@...
To change digest mode or to make other administrative changes visit:
http://music.columbia.edu/mailman/listinfo/jsyn

Re: Using a SampleQueueOutputStream with variable rate sample reader.

by marmadoc :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

music.columbia.edu - JSyn mailing list wrote:
The JSyn clock will not advance until you call sleepUntilTick(x). So
just make sure you have all your other data before you call it.
Thats, good to know.  So, let's look at a multi-threaded app, where the synthContext is created, started and stopped in one location (not really a thread, just a method call e.g. start()), while data input, data output, and other functions are handled by separate threads.

Should sleepUntilTick() be called on all threads involved, and not only on the specific data handling thread?  What happens if one thread calls sleepUntilTick() while another is not ready to do that yet, or should the control of when to sleep only happen from one thread?

Thanks for your time and patience.
Etienne.