SynthMaker

Reversing Incoming Audio

Archive · 2005 20 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

Tom7777 ·

Since im no coder i havent really been using the audio buffer modules which i know its possible to reverse samples but how would i reverse a stereo audio signal? thanks

Shifrin ·

AFAIK you couldn't, if you literally mean you want to reverse an audio input in realtime it's not possible. Think of it this way, say you have a wave file and reverse it, the end becomes the start. You couldn't do this in realtime because you need all the sample data to perform the operation, but you only get a sample at a time from the start. You could write something to read into a buffer and then reverse the buffer as output, this would have a delay equal to the size of the buffer and play 'chunks' of audio in reverse. You could also write a delay effect that plays the delayed signal in reverse too 🙂

I'd love to know if there's a magical way to do what you want 😉

Shif.

Tom7777 ·

You could write something to read into a buffer and then reverse the buffer as output

Yeah this is the type of thing i wanted to know how to do, i know that realtime reversing is not really possible, I was thinking about making a reversed delay actually but im confused as to how i would go about doing so. 😕

rullyastronout ·

i think vst system, has a block of sample given depend on souncard latency setting, before we can start the process. so we actually can reverse the sample between a block of samples, but i don't know how to do it in sm. in c++ you could.

i hope there some one can tell me how to ==>get ablock of sample ==>process it ==>send out at no delay.

angstrom ·

depends if you want any pitch bending or not .. to get a scratch effect. In which case there was a nice scratch sequencing thing posted a while back - or sambean posted a record stop effect (I think it was sam anyway). I mention those because you will need to take a look at their interpolation.

basically, for a simple reverse you should define a block of memory as long as you think you will need and add samples to it like a delay buffer

float mem[352800];// thats about 16 seconds at 120bpm. mem[index] = in; index = index + 1;

stop counting when you run out of buffer or when it's time to reverse. Then, do something like

index = index-1; out = mem[index];

that's roughly it anyway. Start with a basic delay and go from there. Try it , it's fun to make the code window crash 😉

MyCo ·

I just played around with the code from angstrom: http://music-drive.com/rev_reverb.osm

BTW: float mem[352800];// thats about 16 seconds at 120bpm. has to be: float mem[352800];// thats about 7 seconds at 44,1kHz samplerate.

Tom7777 ·

Your link doesn't seem to be working MyCo 🙁

angstrom ·

MyCo wrote: float mem[352800];// thats about 16 seconds at 120bpm. has to be: float mem[352800];// thats about 7 seconds at 44,1kHz samplerate.

😊

I had a delay OSM open at the time I posted - which has a GUI button for 16 seconds, but I hadn't actually made the code capable of that. I should have noticed really as 352,800 / 44,100 = 8

Anyway. 8 seconds is a pretty healthy buffer. 😉

MyCo ·

Tom7777 wrote: Your link doesn't seem to be working MyCo 🙁

Server is down, try again in some hours.

Tom7777 ·

Ok thanks MyCo 🙂

Tom7777 ·

It's working now 🙂

Kingston ·

rullyastronout wrote: i think vst system, has a block of sample given depend on souncard latency setting, before we can start the process. so we actually can reverse the sample between a block of samples, but i don't know how to do it in sm. in c++ you could.

i hope there some one can tell me how to ==>get ablock of sample ==>process it ==>send out at no delay.

That's not what the internal processing blocks (ie the buffer) in VST host does. That's for the hosts internal processing method only.

Basically any effect needs its own buffer where you can store an arbitrary lenght of audio (to be reversed or whatever). This will automatically generate a latency also, and there's just no way around that. We just can't see in the future.

Luckily, if the effect has a "look ahead buffer" like this we could report that to the host which can then (if supported) compensate for it.

Unfortunately there's no way to report the latency of SM plugin to the host.

That feature is high on my wish list.

MyCo ·

Tom7777 wrote: It's working now 🙂

just wanted to say that now... but you were faster.

Tom7777 ·

😀

rullyastronout ·

Luckily, if the effect has a "look ahead buffer" like this we could report that to the host which can then (if supported) compensate for it.

Unfortunately there's no way to report the latency of SM plugin to the host.

That feature is high on my wish list.

o well, look ahead buffer, thats exacly what i mean. so i'll be the second person who put the wish list on top, thanks for info kings. and how about this, does this also called look ahead buffer...

void AGain::processReplacing (float **inputs, float **outputs, long sampleFrames) { float *in1 = inputs[0]; float *in2 = inputs[1]; float *out1 = outputs[0]; float *out2 = outputs[1]; int index=0;

while (--sampleFrames >= 0)//depend on sampleframe given //the look ahead buffer { while(index!=100) { index=index++; float Left[index] = *in1++; } //and so on

Kingston ·

do NOT confuse the VST plugin buffers (host based) with any kind of look ahead buffering. It's (almost) a completely different thing.

You can already easily do "look ahead" buffers in synthmaker, or audio buffers in general. We already have that feature. What we do need is latency reporting to host, but I fear I'm already confusing you even further.

skater130 ·

MyCo wrote: I just played around with the code from angstrom: http://music-drive.com/rev_reverb.osm

BTW: float mem[352800];// thats about 16 seconds at 120bpm. has to be: float mem[352800];// thats about 7 seconds at 44,1kHz samplerate.

I've been searching for hours for a practical example of exactly what I'm aiming to do, and this is it!...except the file is no longer active. If you happened to have a copy MyCo or can explain the inner workings of reversing audio (which can't be done on the fly due to latency - I guess the unprocessed signal can be delayed in order to wait for it to catch up?) It would be deeply appreciated.

(EDIT: Sorry for re-igniting an old thread...hopefully there's still people out there in the know!)

trogluddite ·

Here's a little module that can do the reversing - it's really meant as a pitch shifter (from the algorithm posted HERE), but the same method has the ability to reverse its input buffer, and has crossfades to avoid any nasty clicking.

The 'Window Size' parameter in the properties sets the size of the buffer (and hence the latency).

Leslie147 ·

Trogluddite, thank you very much for sharing that module. I appreciate it was quite a while ago that you posted the .osm file but I hope this gets back to you.

The way you create the slopes is a lesson in compact code writing but I haven't yet managed to figure out the function of absmask=2147483647. Your advice on this would be much appreciated.

When I tried to use the shifter fourfold I spotted 'temping[1]' instead of tempind[1] in writing to the array which prevented one channel from working. Also, I noticed the window size is limited to 1 second by the Float Min 44100 even though the array is sized for a maximum of 10 seconds. Fixing this, I found a 2 second window very musical.

Having deduced and written out the mathematical basis for the way this works, I can see how you reverse time by effectively swapping the sign of t in sinw(t+T) ... given an input signal sinwt. Brilliant! The Vox Tonelab pedal board I have does a time reverse that sounds similar to this but it's good to have it in a form that can be manipulated freely.

Thanks again,

Chris

trogluddite ·

No problem - I can't really take all the credit anyway, as the code was an my assembly optimisation, of another guys code, who ported an algorithm....

The ABSmask is just a very fast way to create the ABS(x) function - the integer has the lowest 31 bits all set to one, and the 32nd bit (sign bit) set to zero. Because float numbers also use the top bit as the sign bit, when you do a bitwise ANS with any 32bit number, the sign bit will be masked out - turning negative numbers into positive ones.

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.