« Return to Thread: single sample delay from buffer; please help

Re: single sample delay from buffer; please help

by Wouter Snoei-2 :: Rate this Message:

Reply to Author | View in Thread

Well, what I'm doing is writing into a buffer with RecordBuf, and  
read out immediately after that. This is why the startpos for PlayBuf  
is below zero. The same thing could be done by giving RecordBuf a  
positive offset and PlayBuf no offset. However, giving PlayBuf a  
positive offset makes the read pointer go before the write pointer,  
and results in a delay as big as the size of the buffer. Which works  
but is not what I want :-).

The bottom line is: as soon as I try to read from and write to a  
buffer frame within the timespan of a control frame (64 samples)  
thing become unstable, resulting in the distortion. This seems to go  
for any UGen I tried to achieve it with. The working example I gave  
earlier was probably a lucky exception. Or was it.. ?

cheers,
Wouter


Op 15-mei-2008, om 17:35 heeft nonprivate het volgende geschreven:

> hi wouter, i must admit i don't understand, but if startPos is -1 then
> the "distortion" is apparent, but if it is set to 1 it isn't. i never
> tried giving startPos negative values before, so i wonder if it's an
> intentional thing in order to do something specific, or something  
> you're
> not supposed to do but sounds interesting anyway.
>
> Wouter Snoei wrote:
>> I copied the code from Tap.ar. PlayBuf has loop:1 here, so
>> startOffset is wrapped internally. Using .wrap has no effect on  
>> result.
>>
>> It seems to be something to do with when the buffer is updated. In
>> the first example this always happens straight away, in the second it
>> seems to sometimes wait for a control frame duration. I want to use
>> this for internal single-sample feedback, but there is no way I can
>> get that to work. As soon as I try to route the delayed into the
>> recordbuf the same distortion problems start showing up as in the
>> second example. Really, can't SC do single-sample feedback? The
>> example in the examples folder only does it at Demand rate. As soon
>> as I mix in audio signals there again the same problems as in the
>> example below start showing up.. help welcome here..
>>
>> cheers,
>> Wouter
>>
>>
>> Op 15-mei-2008, om 17:04 heeft nonprivate het volgende geschreven:
>>
>>
>>> startPos in the PlayBuf is negative, is it supposed to be like that?
>>> interesting effect to play with, using different values.
>>>
>>> Wouter Snoei wrote:
>>>
>>>> Hi all,
>>>>
>>>> can any of you explain why:
>>>>
>>>> b=Buffer.alloc(s, 128, 1);
>>>>
>>>> (
>>>> SynthDef(\tryDelay, {|bufnum, delay = 1|
>>>> var source, capture, delayed;
>>>> source= SinOsc.ar( SinOsc.ar(2).range(400,500), 0, 0.125 );
>>>>   capture = RecordBuf.ar( source, bufnum );
>>>>
>>>>   delayed = PlayBuf.ar(1, bufnum, 1, 0,
>>>>   (delay/SampleRate.ir) * SampleRate.ir.neg,
>>>>   1);
>>>>  
>>>> Out.ar(0, delayed);
>>>>
>>>> }).send(s);
>>>> )
>>>>
>>>> x=Synth(\tryDelay,[\bufnum, b]);
>>>>
>>>> /*
>>>> works but
>>>> */
>>>>
>>>> (
>>>> SynthDef(\tryDelay, {|bufnum, delay = 1|
>>>> var source, capture, delayed;
>>>> source= SinOsc.ar( SinOsc.ar(2).range(400,500), 0, 0.125 );
>>>>   capture = RecordBuf.ar( source, bufnum );
>>>>
>>>>   delayed =  PlayBuf.ar(1, bufnum, 1, 0,
>>>>   delay.neg,   // simplified
>>>>   1);
>>>>  
>>>> Out.ar(0, delayed);
>>>>
>>>> }).send(s);
>>>> )
>>>>
>>>>
>>>> x=Synth(\tryDelay,[\bufnum, b]);
>>>>
>>>> /*
>>>> doesn't work? I get distorted sound with the second one.. Buffer  
>>>> size
>>>> doesn't seem to matter, although at <64 samples I get distorted  
>>>> sound
>>>> on both examples.
>>>> */
>>>>
>>>>
>>>> cheers & thanks,
>>>> Wouter
>>>>
>>>>
>>>>
>>>>
>>>> Wouter Snoei
>>>>
>>>> info@...
>>>> http://www.woutersnoei.nl
>>>>
>>>> _______________________________________________
>>>> sc-users mailing list
>>>> sc-users@...
>>>> http://lists.create.ucsb.edu/mailman/listinfo/sc-users
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> sc-users mailing list
>>> sc-users@...
>>> http://lists.create.ucsb.edu/mailman/listinfo/sc-users
>>>
>>
>> Wouter Snoei
>>
>> info@...
>> http://www.woutersnoei.nl
>>
>> _______________________________________________
>> sc-users mailing list
>> sc-users@...
>> http://lists.create.ucsb.edu/mailman/listinfo/sc-users
>>
>>
>
> _______________________________________________
> sc-users mailing list
> sc-users@...
> http://lists.create.ucsb.edu/mailman/listinfo/sc-users

Wouter Snoei

info@...
http://www.woutersnoei.nl

_______________________________________________
sc-users mailing list
sc-users@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-users

 « Return to Thread: single sample delay from buffer; please help