Change reading speed of sample

Algorithm development and general DSP issues

Moderator: frank

Post Reply
drolo
Posts: 10
Joined: Tue Feb 10, 2015 3:14 am
Location: BE
Contact:

Change reading speed of sample

Post by drolo »

I thought this would be trivial to achieve but I can't seem to figure out how to go about it...
Basically I would like to record a 1s sample and slow it down, or speed it up. Just like a tape recorder, where the pitch also changes.

The best I could get until now is using the method as shown here:
frank wrote:

Code: Select all

mem delay 32767

skp run, loop
sof 0, -0.25
wrax rmp0_rate,0
wrax rmp0_range, 0 
loop:

sof 0,0
rdax adcl, 1.0
wra delay, 0.0 

cho rdal, rmp0
wrax addr_ptr, 0
rmpa 1.0
wrax dacr, 1.0
wrax dacl, 0.0
This code was posted by Frank for a reverse delay. Changing the ramp rate gives me the results I want, but it only allows for a 1/4s long sample.
If someone could give me some pointers on how to get the same for 1 sec, that would be great :-)
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

You may want to try the record/play code from http://www.spinsemi.com/forum/viewtopic ... ght=record and add a pitch shift into the playback routine to shift up/down. The example is stereo but it should be easy to rip out one channel and double the delay for the remaining one.
Frank Thomson
Experimental Noize
drolo
Posts: 10
Joined: Tue Feb 10, 2015 3:14 am
Location: BE
Contact:

Post by drolo »

Thanks Frank
Though wouldn't adding pitch shift not just shift the pitch of the sample?
the actual sample would not be slowed down or sped up ?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Yeah, you are correct. Problem is there is no way to change the playback speed in software it will have to be done via a pitch shift in some manner. Basically the code you posted at the top of this thread is half of a pitch shift so try it in the playback routine.
Frank Thomson
Experimental Noize
knutolai
Posts: 65
Joined: Wed Nov 23, 2016 9:43 am
Location: Bergen, Norway

Post by knutolai »

hey

Have been thinking about this application myself. Why not just do away with the ramp oscillator and increment and reset addr_ptr position directly?

Something like this:

Code: Select all

-Set address increment size (pot ctrl)
-Increment read address
-If read address is beyond delay buffer length (NEG or >32768) 
    ABSA (32768 - (ABSA (addr) ))
-Set ADDR_PTR

-Write ADC + Feedback (pot ctrl) to delay buffer
-Read address with rmpa
-Write to DAC and feedback reg

drolo
Posts: 10
Joined: Tue Feb 10, 2015 3:14 am
Location: BE
Contact:

Post by drolo »

Thanks for the tip (and sorry for the late reply, for some reason I never get notifications for post replies)

I was thinking about trying something like this but will need to free up some time to work on it and wrap my head around how to make it work :-)

Your pointers are going to help for sure
knutolai
Posts: 65
Joined: Wed Nov 23, 2016 9:43 am
Location: Bergen, Norway

Post by knutolai »

got around to test the concept. It does work. No need to deal with the ramp function. The sound will get very grainy as you slow it down. Nice spooky vibe when playback is done in reverse at half (or quarter) tempo. Octave down stuff.
igorp
Posts: 65
Joined: Tue May 19, 2015 6:10 am
Location: RU

Post by igorp »

Also, you may write your own ramp LFO. Without crossfades, etc, it's easy -> usual DDS
Post Reply