From jsyn at music.columbia.edu Fri Aug 24 02:35:23 2007 From: jsyn at music.columbia.edu (jsyn@music.columbia.edu) Date: Fri Aug 24 02:37:37 2007 Subject: [jsyn] (Re)Sampling audio at different rate. Message-ID: <12307352.post@talk.nabble.com> Hi Phil, I have the following scenario: A synth context is set up and running at an audio rate of 44100. I now want to provide the output sampled at a different rate e.g. 24000. There is not a SampleWriter_16V1 available which would solve my problem, so the only alternative I can think of is to create a separate synth context, running at the audio rate required, and use a SampleReader_16V1 set to 44100 on the input. Then I just need to continually port the data between the two contexts. Do you agree with this method, or is there another way of doing it? Your help is always appreciated. Thanks, Etienne. -- View this message in context: http://www.nabble.com/%28Re%29Sampling-audio-at-different-rate.-tf4321934.html#a12307352 Sent from the music.columbia.edu - JSyn mailing list archive at Nabble.com. From jsyn at music.columbia.edu Sun Aug 26 04:40:43 2007 From: jsyn at music.columbia.edu (jsyn@music.columbia.edu) Date: Sun Aug 26 04:38:31 2007 Subject: [jsyn] (Re)Sampling audio at different rate. In-Reply-To: <12307352.post@talk.nabble.com> References: <12307352.post@talk.nabble.com> Message-ID: <46D13C8B.7070705@softsynth.com> Hello Ettienne, Running SynthContexts at different rates can be difficult. It may cause a hardware conflict on some devices. Are you on Mac or PC? > I now want to provide the output sampled at a > different rate e.g. 24000. Are you doing realtime output or writing to a file or a network? I cannot think of a solution to this... But I might if I knew more about what you were trying to do. 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@music.columbia.edu wrote: > Hi Phil, > > I have the following scenario: A synth context is set up and running at an > audio rate of 44100. I now want to provide the output sampled at a > different rate e.g. 24000. > There is not a SampleWriter_16V1 available which would solve my problem, so > the only alternative I can think of is to create a separate synth context, > running at the audio rate required, and use a SampleReader_16V1 set to 44100 > on the input. Then I just need to continually port the data between the two > contexts. > > Do you agree with this method, or is there another way of doing it? > > Your help is always appreciated. > > Thanks, > Etienne. From jsyn at music.columbia.edu Sun Aug 26 05:21:06 2007 From: jsyn at music.columbia.edu (jsyn@music.columbia.edu) Date: Sun Aug 26 05:21:07 2007 Subject: [jsyn] (Re)Sampling audio at different rate. In-Reply-To: <46D13C8B.7070705@softsynth.com> References: <12307352.post@talk.nabble.com> <46D13C8B.7070705@softsynth.com> Message-ID: <12333333.post@talk.nabble.com> Hi Phil, Thanks for your reply. music.columbia.edu - JSyn mailing list wrote: > > Are you on Mac or PC? > I'm not 100% sure of the final platform of the client, but I think we can assume PC for now. music.columbia.edu - JSyn mailing list wrote: > > Are you doing realtime output or writing to a file or a network? > Actually both. I want to be able to write to file while processing (non-realtime) and separately write to file/network while playing realtime. music.columbia.edu - JSyn mailing list wrote: > > I cannot think of a solution to this... > Maybe it is not necessary to use JSyn for the resampling at all. After some reading I realised that the resampling can be done directly on the data received from the output of the SynthContext. I have found some libraries mainly written in C that are able to do resampling (with decimation/interpolation and filtering). I think this would help, but are currently first looking for a Java lib to do the same. Do you know of any such Java libraries? Doesn't JSyn perhaps have a built in resampler that can be used outside of a SynthContext (since you have to resample for input signals not on the same audio rate as the engine)? Thanks for you time, Etienne. -- View this message in context: http://www.nabble.com/%28Re%29Sampling-audio-at-different-rate.-tf4321934.html#a12333333 Sent from the music.columbia.edu - JSyn mailing list archive at Nabble.com. From jsyn at music.columbia.edu Mon Aug 27 13:47:38 2007 From: jsyn at music.columbia.edu (jsyn@music.columbia.edu) Date: Mon Aug 27 13:45:20 2007 Subject: [jsyn] (Re)Sampling audio at different rate. In-Reply-To: <12333333.post@talk.nabble.com> References: <12307352.post@talk.nabble.com> <46D13C8B.7070705@softsynth.com> <12333333.post@talk.nabble.com> Message-ID: <46D30E3A.1050303@softsynth.com> Hello Ettiene, It is good that at least one of the outputs is non-real-time, or at least not connected to a physical audio device. That makes it much easier. > Actually both. I want to be able to write to file while processing > (non-realtime) and separately write to file/network while > playing realtime. Since you will be bringing audio up into Java for export, you might as well resample in Java as you mentioned. JSyn just does a simple linear interpolation for performance reasons. Since you are probably just doing one stream you could do a fancier spline or other form of interpolation. JSun does not have any Java based resampling tools. The trickiest part may be handling clock drift. If the network consumer is running at a slightly different rate for a long time then your buffers will overflow or underflow. You might need to monitor the buffers and slowly adjust your rate to avoid that. The trick is doing that in a way that is not noticeable. 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 ---------------------------------------