Reversing Incoming Audio

Sound synthesis techniques, DSP and related mathematics

Moderators: electrogear, exonerate

Reversing Incoming Audio

Postby Tom7777 on Wed Oct 26, 2005 4:54 pm

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
Tom7777
smychopath
 
Posts: 3936
Joined: Wed Mar 16, 2005 10:46 pm

Postby Shifrin on Wed Oct 26, 2005 5:09 pm

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 :wink:

Shif.
User avatar
Shifrin
smaniac
 
Posts: 1498
Joined: Sun Mar 06, 2005 1:54 pm
Location: Newcastle, UK

Postby Tom7777 on Wed Oct 26, 2005 5:15 pm

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. :S
Tom7777
smychopath
 
Posts: 3936
Joined: Wed Mar 16, 2005 10:46 pm

Postby rullyastronout on Wed Feb 22, 2006 9:57 pm

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.
rullyastronout
essemer
 
Posts: 12
Joined: Mon Feb 20, 2006 5:39 pm
Location: Jakarta, Indonesia

Postby angstrom on Wed Feb 22, 2006 10:14 pm

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 ;)
User avatar
angstrom
smanatic
 
Posts: 724
Joined: Tue Apr 26, 2005 12:46 pm

Postby MyCo on Thu Feb 23, 2006 4:37 am

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.
User avatar
MyCo
smaniac
 
Posts: 1016
Joined: Mon Dec 19, 2005 1:43 am
Location: Germany

Postby Tom7777 on Thu Feb 23, 2006 12:09 pm

Your link doesn't seem to be working MyCo :(
Tom7777
smychopath
 
Posts: 3936
Joined: Wed Mar 16, 2005 10:46 pm

Postby angstrom on Thu Feb 23, 2006 1:01 pm

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.


:blush:

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. ;)
User avatar
angstrom
smanatic
 
Posts: 724
Joined: Tue Apr 26, 2005 12:46 pm

Postby MyCo on Thu Feb 23, 2006 3:39 pm

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


Server is down, try again in some hours.
User avatar
MyCo
smaniac
 
Posts: 1016
Joined: Mon Dec 19, 2005 1:43 am
Location: Germany

Postby Tom7777 on Thu Feb 23, 2006 3:45 pm

Ok thanks MyCo :)
Tom7777
smychopath
 
Posts: 3936
Joined: Wed Mar 16, 2005 10:46 pm

Postby Tom7777 on Fri Feb 24, 2006 3:43 pm

It's working now :)
Tom7777
smychopath
 
Posts: 3936
Joined: Wed Mar 16, 2005 10:46 pm

Postby Kingston on Fri Feb 24, 2006 5:12 pm

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.
Kingston
essemilian
 
Posts: 209
Joined: Sat Nov 26, 2005 8:03 pm

Postby MyCo on Fri Feb 24, 2006 5:18 pm

Tom7777 wrote:It's working now :)


just wanted to say that now... but you were faster.
User avatar
MyCo
smaniac
 
Posts: 1016
Joined: Mon Dec 19, 2005 1:43 am
Location: Germany

Postby Tom7777 on Sat Feb 25, 2006 6:14 pm

:D
Tom7777
smychopath
 
Posts: 3936
Joined: Wed Mar 16, 2005 10:46 pm

kingston

Postby rullyastronout on Mon Feb 27, 2006 9:55 pm

Code: Select all
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...
Code: Select all
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
 
rullyastronout
essemer
 
Posts: 12
Joined: Mon Feb 20, 2006 5:39 pm
Location: Jakarta, Indonesia

Next

Return to Sound

Who is online

Users browsing this forum: No registered users and 1 guest