Page 1 of 1

Change reading speed of sample

Posted: Mon Jul 10, 2017 4:59 am
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 :-)

Posted: Mon Jul 10, 2017 9:14 am
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.

Posted: Mon Jul 10, 2017 1:28 pm
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 ?

Posted: Mon Jul 10, 2017 2:56 pm
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.

Posted: Sat Jul 22, 2017 4:40 am
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


Posted: Mon Jul 31, 2017 11:09 am
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

Posted: Fri Aug 04, 2017 1:37 pm
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.

Posted: Tue Oct 03, 2017 11:01 pm
by igorp
Also, you may write your own ramp LFO. Without crossfades, etc, it's easy -> usual DDS