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?
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…;-)
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.
----------begin_max5_patcher---------- 1539.3oc4assjhhDD8Y8qffXer2NpKTbYeZ222+fM1XBTKsqYQv.vd5YlX5u 8stgB1BlpXYO87BBkEEm7jYdprJwuOch+rhW3U9d+g2+3MYx2mNYhtIUCSrW Owec5KyyRqzcyedw5077Z+GLeWM+kZS6Yh4+mW8ShpluJe6ZQdFuVeeXaiKK xqqDeiqai7HZeeK1V2z4lV2TxqjOqzZQQ9mJ4yqM.MHgIuQu.8Qj8f2+17DJ WMSOH6F7Mo0yeRjupug.yzCBo8nHVnsphYe92oI9s.ed5ZM38+qRQZlu5K9w zopCO.jAmssttHePVpKczzpoo5utgaLB+Yo4q72A4iYlgsLSxvVY7kXK8EMT usL2Kc6BQg2IL0yJf.jukQLlKFAw4FNtN29HjJds2BdV5WqbMaDoseZHH1Hv crwpTQtyIiXcngMB4TjAYbIC92VjN+0iZwjgkA6MwF2VFSc7n1A5RPqx8rCr aRKkleMu7S77zYY71nCfgPFVOOLJV6GhCOpf9aj8pDqxktfG77ExXqA0+RZ6 uizGo83tIIuyoIVhIbMNXzoIzYPSwu2oIL1PSzwlln3yflhduPSWgASHmgAG dIF7ZdUU5J9alf32vdLzfRkflb.ehBIalG.XnBDxhZxRCzAg33dHK53N0xxr BogCIvQdah0xtJahgPnGQW8DvDXbLAHGKMkzZUvY2haknqA2CNCeiWvTtyvS vSF4pcx4eQNruIVN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Gh6vCjhUN.z2zjcHhOX2EOignMic2LWXHwONDNPTevNL7A h3L1co6zQvacvJAHT8RbnAs+og5dk8ezBCo6o9pawB3FgokGz1ruQGcup4ug G9taaQWksg5Xan11Fkb2ssvqw1raUd2qr1lsm2JaCR5u6J9.CpXH2AGHK6wc Zif1mjH2QOQfJr+RidLaFX5lMOyKqrioFJ9qS+rY2Y06rs50zxbodD8K4OKZ 5ezT0n8io+O.sXzjE -----------end_max5_patcher-----------
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.