Axo delay implementation


#21

get the types correct e.g. float array, and using q27_to_float(), float_to_q27()

seriously, don't get into the (really) bad habit of casting to fix compilation errors, i promise you long term this will cause you real grief... its one of the most common sources of bugs!
( basically, casting is saying to the compiler, im not interested in you telling me about the bugs i have in my code :wink:)

... where casting is required, there are better ways in modern compilers (static_cast, dynamic_cast)

btw, the reason I've pointed you to using floats, is not for the delay,( for that you can simply use int32_t) , but because when the you want to start doing things like 'wet/dry' mixes, or feedback loops, the maths is much easier (/obvious) with floats that using q27 maths.


#22

That is what i have been doing, trying to anyway haha.

I will stay away from casting, was just trying out spuntki's solution, but didn't work so back to trying to find a fix with floats.
Ye i get your point about using floats, trust! I don't think i could have even got this far with q27 maths as all my uni stuff is in float, so i know that in the short-ish time frame i have left, there is no point trying to get my head around the q27 maths as it's a struggle still with the floating point version!


#23

Little update on this one, so far i've managed to configure the buffers correctly (that took a long time!), so i can get audio into and out of a buffer.
Then with the delay time, it all complies fine which is great, also took a fair bit of fiddling about but the issue I've come to now, is actually delaying the signal, i really don't understand why the code that used to work doesn't with axoloti, that being.

BufferReadPos = BufferWritePos - time;
if(BufferReadPos < 0) BufferReadPos = 0;

When i run an impulse through, the delayed signal is just the same as the input signal with no change in time, so although time has a value (lets say 10,000), it doesn't do anything to the read pointer for some reason, even though everything is the same type (float) and the code works (on xcode).

Any ideas ? Thanks simple delay.axo (4.8 KB)


#24

Your original code wouldn't work due to the issue I mentioned. ( uint and not implementing a circular buffer correctly)


#25

When i say the code works, i have adapted it so far to work inside axoloti rather than a PC, so i really only mean the flow of things rather than a copy paste job. Those issues have been sorted along the way and are fixed.


#26

ive just taken a look at your new code, but its still got the same basic issue - this code will not work

	readpos = writepos - time;
	if(readpos < 0)	
	{
		readpos = 0;                                 //read pos wrapper
	}

please see my previous reply for why......
(hint, for writepos = 1,2,3,4 you will set readpos to 0, this is incorrect!)

I'm confused you say it works under xcode... to me the algorithm looks wrong.
(well to be precise, it would 'appear' to work only under limited circumstances, when the writepos is not near the start of the delay line)

personally, id draw this on a piece of paper, and work thru it, once you have worked out the algorithm its trivial to implement.

the issue, is real time programming (including audio stuff) is tricky to debug, its better to spend more time upfront working out the design/algo .... this is a different 'workflow' for some programmers, who have become reliant on debuggers ( quite common these days with modern IDEs)

EDIT:
btw, a tip
initially develop objects as embedded objects, its a much quicker workflow.
also then you can upload the axp here, and we can look at it with one click.
( with axo, I have to save the file, move it into an objects directory, and then reload objects... much more hassle :wink:)