Csound Csound-dev Csound-tekno Search About

[Csnd] Sample-accurate delay

Date2020-07-30 18:56
FromAlex Weiss
Subject[Csnd] Sample-accurate delay
For an instrument I'm building I need to specify the delay in samples. Delay times will be under 1s on average but it is pivotal that they're sample-accurate.

Obviously, I can convert from samples to seconds but is the resolution of floats accurate enough to be able to resolve to each individual sample from, say, 0 to 48000?
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-07-30 23:01
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Sample-accurate delay
Use delayr/delayw and deltapn which takes an integral number of delay samples.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 30 Jul 2020, at 18:57, Alex Weiss <alexweiss86@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

For an instrument I'm building I need to specify the delay in samples. Delay times will be under 1s on average but it is pivotal that they're sample-accurate.

Obviously, I can convert from samples to seconds but is the resolution of floats accurate enough to be able to resolve to each individual sample from, say, 0 to 48000?
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-07-31 02:53
FromAlex Weiss
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Sample-accurate delay
Thanks. On a similar note, when scheduling instruments, how are p2 times rounded to the nearest ksmps boundary? Are they always rounded up or down?

On Thu, Jul 30, 2020 at 3:01 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Use delayr/delayw and deltapn which takes an integral number of delay samples.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 30 Jul 2020, at 18:57, Alex Weiss <alexweiss86@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

For an instrument I'm building I need to specify the delay in samples. Delay times will be under 1s on average but it is pivotal that they're sample-accurate.

Obviously, I can convert from samples to seconds but is the resolution of floats accurate enough to be able to resolve to each individual sample from, say, 0 to 48000?
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-07-31 05:14
FromKevin Welsh
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Sample-accurate delay
I had written a UDO a while back that used a k-rate array with ksmps=1 as a buffer and shiftin and shiftout.  I don't know if this is an acceptable way to do it, but it seemed to work ok when I tried.

; UDO to delay by a specific number of samples
opcode DelaySample,aa,aak
  aSigL, aSigR, kSamples xin
  setksmps 1

  if(changed(kSamples)==1) then
    reinit DelaySampleReinit
  endif

  DelaySampleReinit:
  iSamples = round(i(kSamples))
  if (iSamples>0) then
    kBufL[] init iSamples
    kBufR[] init iSamples

    aOutL shiftout kBufL
    aOutR shiftout kBufR

    kBufL shiftin aSigL
    kBufR shiftin aSigR
  else
    aOutL = aSigL
    aOutR = aSigR
  endif
  xout aOutL, aOutR
endop

On Thu, Jul 30, 2020 at 9:54 PM Alex Weiss <alexweiss86@gmail.com> wrote:
Thanks. On a similar note, when scheduling instruments, how are p2 times rounded to the nearest ksmps boundary? Are they always rounded up or down?

On Thu, Jul 30, 2020 at 3:01 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Use delayr/delayw and deltapn which takes an integral number of delay samples.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 30 Jul 2020, at 18:57, Alex Weiss <alexweiss86@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

For an instrument I'm building I need to specify the delay in samples. Delay times will be under 1s on average but it is pivotal that they're sample-accurate.

Obviously, I can convert from samples to seconds but is the resolution of floats accurate enough to be able to resolve to each individual sample from, say, 0 to 48000?
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-07-31 09:18
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Sample-accurate delay
They are rounded to the nearest ksmps boundary, unless --sample-accurate is used, then Csound starts playing the instrument at the time requested. 

Prof. Victor Lazzarini
Maynooth University
Ireland

On 31 Jul 2020, at 02:54, Alex Weiss <alexweiss86@gmail.com> wrote:


Thanks. On a similar note, when scheduling instruments, how are p2 times rounded to the nearest ksmps boundary? Are they always rounded up or down?

On Thu, Jul 30, 2020 at 3:01 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Use delayr/delayw and deltapn which takes an integral number of delay samples.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 30 Jul 2020, at 18:57, Alex Weiss <alexweiss86@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

For an instrument I'm building I need to specify the delay in samples. Delay times will be under 1s on average but it is pivotal that they're sample-accurate.

Obviously, I can convert from samples to seconds but is the resolution of floats accurate enough to be able to resolve to each individual sample from, say, 0 to 48000?
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here