[PD] copy data between arrays

Giulio Moro giuliomoro at yahoo.it
Tue Apr 23 15:23:28 CEST 2024


If you need 'instantaneous' (zero logical time) copy, then [array get] and [array set] are probably a good option, but even though this will not stop the DSP, it may well cause an audio dropout, typically in the case of large copies on a system with small blocksize and small buffer size and non-trivial CPU usage. These factors all interact in determining how much headroom (in terms of CPU time) there is for a copy to happen within a single audio callback without causing a buffer underrun.
If you need a real-time friendly[1] copy, consider using a pair of tabread~ / tabwrite~. In this case, if you need to copy faster than real time[2] (i.e.: copy one second worth of data in less than one second), you should be able to do that in an oversampled  subpatch(via [block~]).

[1]: real-time friendly in the sense of the very loose definition of an operation that completes in a finite amount of time and that has an (almost) constant CPU time for each audio callback.
[2]: real time as in real-world time in seconds given by arraySize/samplingRate

Benjamin Wesch wrote on 23/04/2024 10:38:
> hi,
> 
> to avoid confusion here: the "clipboard" in this case is actually a file.
> it certainly works to write and read arrays to/from disk like that (as
> documented in "other-messages" subpatch of the [array define] help) -
> but this is not a RAM copy/paste as it might seem. :)
> 
> cheers,
> ben
> 
> Am Di., 23. Apr. 2024 um 10:29 Uhr schrieb Peter P. <peterparker at fastmail.com>:
>>
>> Thanks for this hint Oliver!
>>
>> Can't test right now but am curious if audio drops out (eg. playing a
>> sine test tone while copying some 10secs of table data) and if there is
>> any (dis)advantages over the get/set method below.
>>
>> cheersz, P
>>
>> * oliver at klingt.org <oliver at klingt.org> [2024-04-23 10:22]:
>>> Also just found out by chance that writing and reading to/from clipboard also works !
>>>
>>> [write clipboard(
>>> |
>>> [array define a1]
>>>
>>>
>>> [read clipboard(
>>> |
>>> [array define a2]
>>>
>>> Can you confirm this ?
>>>
>>> Best
>>>
>>> Oliver
>>>
>>>
>>>
>>>
>>>
>>> Am 23. April 2024 10:15:00 MESZ schrieb "Peter P." <peterparker at fastmail.com>:
>>>> Replying to myself here, after this solution has been suggested to me
>>>> off-list:
>>>>
>>>> [bang(
>>>> |
>>>> [array get one]
>>>> |
>>>> [array set two]
>>>>
>>>> seems to work for larger tables without audio dropouts.
>>>>
>>>> Much appreciated help, thanks!
>>>> P
>>>>
>>>> * Peter P. <peterparker at fastmail.com> [2024-04-23 08:54]:
>>>>> Hi list,
>>>>>
>>>>> I am sure this has been asked many times, but I can't find a solution in
>>>>> the mailing list archive. How can I copy data between arrays, in my case
>>>>> arrays of 480000 samples without using externals and without blocking
>>>>> the DSP computation (causing dropouts)?
>>>>> I know that I can write to disk and read from it again, but is there a
>>>>> way that does not require disk access?
>>>>>
>>>>> Thanks for all ideas!
>>>>> Peter
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Pd-list at lists.iem.at mailing list
>>>> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
>>>>
>>>
>>> --
>>>
>>> Gesendet von meinem Endgerät
>>>
>>
>>> _______________________________________________
>>> Pd-list at lists.iem.at mailing list
>>> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
>>
>>
>>
>>
>> _______________________________________________
>> Pd-list at lists.iem.at mailing list
>> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
> 
> 
> 
> _______________________________________________
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
> 





More information about the Pd-list mailing list