Spin Semiconductor Forum Index Spin Semiconductor
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reverse delay?
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    Spin Semiconductor Forum Index -> FV-1 software questions
View previous topic :: View next topic  
Author Message
Digital Larry



Joined: 12 Nov 2012
Posts: 275

PostPosted: Mon Jun 19, 2017 8:23 pm    Post subject: Reply with quote

Few comments.

1) Best place to ask about SpinCAD is over at my forum.

2) Someone sent me the reverse delay code and I slapped it into SpinCAD without thinking about it very much. Off the top of my head I do not know how it works. It could be improved no doubt. Reverse engineering FV-1 code makes my brain hurt.

3) If you come up with an improved version and would like me to include it in SpinCAD, please let me know.

Thanks,

DL
Back to top
View user's profile Send private message Visit poster's website
the_frey



Joined: 04 Jun 2016
Posts: 13

PostPosted: Wed Jun 21, 2017 1:25 am    Post subject: Reply with quote

Cool, was just curious. The crossfade is very dreamy, I was basically wanting to get something going with that. I'll reverse engineer it and see what I can do Smile
Back to top
View user's profile Send private message
knutolai



Joined: 23 Nov 2016
Posts: 32
Location: Bergen, Norway

PostPosted: Wed Jun 21, 2017 2:21 am    Post subject: Reply with quote

Reviving an old thread!

I wrote this code that gets you 500 ms of reverse delay. The delay time, or rather the size of each reversed segment can be adjuster with POT0.

The program uses a counter to increment ADDR_PTR to read though the delay buffer at double the speed of the audio samples (creating reverse playback). I'm having trouble properly removing the "click" sound when the "read head" wraps around/resets. I need to add some kind of envelope that gradually mutes the signal when the "read head" approaches the end of the delay buffer, and gradually un-mutes it when it has reset.

I've tried a couple of things, all very crude. Any suggestions would be great!

Code:
; Reverse Delay
; Knut Helle
; June 2017
;
; POT0 = Reverse segment length
;
equ   length   32767    ; Buffer length
equ   inc   512   ; increment
;
mem   echo   length   ; Delay Buffer
;
equ   addr   reg0   ; rmpa / addr_ptr addres
equ   size   reg1   ; delay buffer size value
;
; Startup Initialization ################################
;
skp   RUN,   loop
clr
wrax   addr, 0      ; Clear reg on startup
loop:
;
; Reset address pointer ################################
;
sof   0, 0.1      ; +0.1
rdax   POT0, 0.9   ; Pot / 'size' range 0.1 to 1
wrax   size, 0      ; write to reg, clear
;
clr   
or   length*256   ; add max delay addres   ( or 8388352 )
mulx   size      ; * size variable
rdax   addr, -1      ; subtract current addres
;
skp   GEZ, reset   ; if NEG (addr > max addres)
clr
wrax   addr, 0      ; Reset addr ( = 0 )
reset:
;
; Set address pointer    USES '-1' instead og 1.0 for better accuracy ###################
;
clr         ; acc = 0
or   inc      ; add increment (+)
sof   -1, 0      ; -> (-)
rdax   addr, -1      ; add addr (-)
sof   -1, 0      ; -> (+)
wrax   addr, -1      ; write to addr, then (-)
sof   -1, 0      ; -> (+)
wrax   ADDR_PTR, 0   ; write to addr_ptr (+), clear acc
;
; Audio In/Out   ###########################################
;
ldax   ADCL      ; Get input
wra   echo, 0      ; Write it to the head of the delay buffer
rmpa   1      ; Read from memory (set by ADDR_PTR)
wrax   DACL, 0      ; ACC-> DAC
Back to top
View user's profile Send private message
Digital Larry



Joined: 12 Nov 2012
Posts: 275

PostPosted: Wed Jun 21, 2017 4:57 am    Post subject: Reply with quote

Some high level thoughts about putting crossfades on the ends of knulotai's code.

The delay time goes from 0.1 to 1.0 times the pot setting. So the minimum would be 100 msec at 32 kHz if you allocated the whole memory for this.

A 50 msec fade is probably fine.

You can check whether addr_ptr is near either end of the buffer and whether a fade up or fade down is in order.

Big question here is whether you are just going to fade up and down at the ends to get rid of the glitch, or are you going to crossfade to something else? If your plan is to crossfade then you would need either another trailing pointer running at mid buffer, or maybe a separate buffer.

- a parenthetical note about writing blocks for SpinCAD - you can't make simplifying assumptions such as being sure that the memory buffer always starts at zero. I wish! But you have to assume that the buffer will have an offset.
Back to top
View user's profile Send private message Visit poster's website
knutolai



Joined: 23 Nov 2016
Posts: 32
Location: Bergen, Norway

PostPosted: Wed Jun 28, 2017 2:31 am    Post subject: Reply with quote

Quote:
The delay time goes from 0.1 to 1.0 times the pot setting. So the minimum would be 100 msec at 32 kHz if you allocated the whole memory for this.

A 50 msec fade is probably fine.


The minimum "read window" would be 100 msec, but that translates to 50ms of reverse delay. The problem might be that I've made the fade out/in too sharp. I'll try to change the delay time pot to 0.2 to 1.0 and add 50ms fade in and 50ms fade out. A 50ms fade would be spread across ~1639 program cycles.

Quote:
You can check whether addr_ptr is near either end of the buffer and whether a fade up or fade down is in order.


Good idea. Something like this would add a linear fade. Might be good enough:
Code:

increment = +/- 1/(32768*0.050) = +/- 0.00061   ; will increment from 0 to 1 in 50ms

if ADDR_PTR < [pot-derived buffersize - 1639]   ; if less than fade out point
   increment = +(1/1639)  ; Positive increment, Fade In (1 + increment = 1 because of reg value limit)
else if ADDR_PTR>= [pot-derived buffersize - 1639]   ; if at or beyond fade out point
   increment = -(1/1639)   ; Negative increment, Fade Out

volume = volume + increment   ; add increment
if volume < 0   ; if less than 0 : set to 0
   volume = 0

Back to top
View user's profile Send private message
drolo



Joined: 10 Feb 2015
Posts: 10
Location: BE

PostPosted: Tue Aug 29, 2017 12:47 am    Post subject: Reply with quote

knutolai wrote:
Reviving an old thread!

I wrote this code that gets you 500 ms of reverse delay. The delay time, or rather the size of each reversed segment can be adjuster with POT0.

The program uses a counter to increment ADDR_PTR to read though the delay buffer at double the speed of the audio samples (creating reverse playback). I'm having trouble properly removing the "click" sound when the "read head" wraps around/resets. I need to add some kind of envelope that gradually mutes the signal when the "read head" approaches the end of the delay buffer, and gradually un-mutes it when it has reset.

I've tried a couple of things, all very crude. Any suggestions would be great!

Code:
; Reverse Delay
; Knut Helle
; June 2017
;
; POT0 = Reverse segment length
;
equ   length   32767    ; Buffer length
equ   inc   512   ; increment
;
mem   echo   length   ; Delay Buffer
;
equ   addr   reg0   ; rmpa / addr_ptr addres
equ   size   reg1   ; delay buffer size value
;
; Startup Initialization ################################
;
skp   RUN,   loop
clr
wrax   addr, 0      ; Clear reg on startup
loop:
;
; Reset address pointer ################################
;
sof   0, 0.1      ; +0.1
rdax   POT0, 0.9   ; Pot / 'size' range 0.1 to 1
wrax   size, 0      ; write to reg, clear
;
clr   
or   length*256   ; add max delay addres   ( or 8388352 )
mulx   size      ; * size variable
rdax   addr, -1      ; subtract current addres
;
skp   GEZ, reset   ; if NEG (addr > max addres)
clr
wrax   addr, 0      ; Reset addr ( = 0 )
reset:
;
; Set address pointer    USES '-1' instead og 1.0 for better accuracy ###################
;
clr         ; acc = 0
or   inc      ; add increment (+)
sof   -1, 0      ; -> (-)
rdax   addr, -1      ; add addr (-)
sof   -1, 0      ; -> (+)
wrax   addr, -1      ; write to addr, then (-)
sof   -1, 0      ; -> (+)
wrax   ADDR_PTR, 0   ; write to addr_ptr (+), clear acc
;
; Audio In/Out   ###########################################
;
ldax   ADCL      ; Get input
wra   echo, 0      ; Write it to the head of the delay buffer
rmpa   1      ; Read from memory (set by ADDR_PTR)
wrax   DACL, 0      ; ACC-> DAC


Knut, this is great !
(still not getting notifications for post replies ...)
Between this and your advice on the other thread about playback speed, I was able to understand a lot better how the memory can be addressed in different ways. This has been really helpful. Thanks !! Smile
Back to top
View user's profile Send private message Visit poster's website
potul



Joined: 25 Sep 2017
Posts: 5

PostPosted: Fri Dec 01, 2017 4:42 am    Post subject: Reply with quote

Hi

Were you able to add a crossfade to the reverse delay?
I like your code, but the cliking is quite annoying.

Mate
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Spin Semiconductor Forum Index -> FV-1 software questions All times are GMT - 8 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group