Frame-based and real-time audio processing(read, delay and filter, write)in MSP?
Hello. I'm not new to DSP but still new to MAX/MSP/Jitter, started about 2 weeks ago.
What I'm going to do is quite simple if I implement it in MATLAB. All I want to do is...
- to read a wave file to (input) buffer,
- duplicate it a few times i.e. other (processing) buffer, length may be 512 or 1024,
- add different delays to each (processing) buffer, apply different FIR filter,
- then playback them into different output channels.
So I tried as below.
- First, send a read message to buffer~ named 'inSigBuf' (which indicates input signal buffer).
Also created a patcher for the calculation of the sample index for each frame, e.g. output these numbers in order when got a bang, [1 1024] [513 1536] [1025 2048] .... . (Based on the assumption that the frame size is 1024 samples and hope size is 512).
-Well, then I defined another input buffer named 'midBuf', whose size is same as input frame size.
Also added 'poke~ midBuf', to write the samples in a section (1 to 1024, then 513 to 1536, ...) into midBuf.
- Next, I added an object 'index~ inSigBuf',
So, I want to send signal in the section of inSigBuf, to 'poke~ midBuf'.
Well, the problem is the synchronization of midBuf and inSigBuf. I'm using 'count~' object for the sample information(counting) of 'index~ inSigBuf', while a 'counter' is used for 'poke~ midBuf'. Cause the 'index~' and 'poke~' works based on different counter, it does not work as I intended. Is there any advice or examples similar with my project?
Thank you.
Keunwoo. Choi.
Why don't you just have multiple buffer~s and load the same wave file? Then you get your copies already. Play them back with groove~, play~ or wave~ add tapin~/tapout~ pairs for the delay, buffir~ or biquad~ for the filter and you are done...;-)
I didn't look at you patch, to avoid building a solution for you. It will be more fun for you to wade through the help files of the mentioned objects and patch it together with a lot of trial and error you can listen to in real time...
I once transferred a MATLAB program to mxj~, but for what you want to do its much easier to do it with standard objects. The way of thinking is very different to MATLAB (or any lines of code) based signal processing. Its at least a 1000 times easier. You want to think about sound, not about samples...
Best is to forget the MATLAB code completely, free your brain and think about what you want to achieve...;-)
good luck
Stefan
Thanks Stefan for your advice. I've been work with MATLAB for 4~5 years while spend few days with MAX, so the concepts are still vague to me.
The goal of my patcher is to apply different delays, gains and filters for every output signal. However, the parameters for such changes are not static, but dynamic as time goes by, based on user's input. For those things I need to implement this code in real-time and frame-based manner.
I'm digging on jit.buffer, jit.peek, jit.release, jit,catch, jit.poke, jit.spill, jit.fill... as well as buffer~, peek~, poke~, index~ and Etc. It's quite difficult for me now.
Do I need to use Jitter objects? The Jitter tutorial #48 "Frames of MSP Signals' introduces Jitter objects for frame processing. Does it means that I need to read the audio file into audio buffer, 'buffer~', then convert it into jitter matrix with 'jit.catch', 'jit.buffer' or 'jit.poke'? I don't think I need those Jitter things, but having troubles for implementing with MSP objects (index, poke, and peek). Oh God, please. I'm more than ready to spend my time fighting with those patchers, but please tell me which objects are needed TT
I think you're thinking about this too much.
One buffer, one playback, different delays and gains. Filters wouldn't be hard to implement this way, i was just lazy and only spent about 4 minutes on this.
With your talk of frame-based stuff, I'm thinking MAYBE you're looking for the FFT suite of objects - check out the helpfile for [pfft~] and the various FFT functions.
Looking at your patch now, you might be better off looking into granular synthesis (this looks like a granular engine with a lot of math that's over my head). Check out sugarSynth (search the forums), "granular 2.5" and the granular example in the C74 examples folder. Similar concept to what you're doing (which sounds essentially like sugarSynth, minus windowing, and with very small grain sizes).
@MuShoo I wish it's okay without frame-based stuff, but I need it for the extendability. The sugarSynth or granula examples are great, though they contains a lot of things more than I can recognize. Thanks MuShoo, even I couldn't see how to do yet.