Csound Csound-dev Csound-tekno Search About

[Csnd-dev] Feature suggestion

Date2022-01-09 09:33
FromAnders Genell
Subject[Csnd-dev] Feature suggestion
I might have asked something similar long ago, but I don’t remember what the answer was, and perhaps things have changed for upcoming 7.0 so here I go again:

Would it be possible to add functionality for allowing a different sr in user opcodes?

The reason I ask is that I have a use case where I would like to be able to use some fairly steep, narrow band filters for low frequencies, and it’s difficult to get stable results without reducing sampling frequency. I was thinking that a first implementation could be a simple 2, 4, 8 etc factor reduction of sr. 
… perhaps this could be done using an externally generated impulse response and a straight up multiplication using arrays and fft opcodes?

Regards,

Date2022-01-09 12:52
FromOeyvind Brandtsegg
SubjectRe: [Csnd-dev] Feature suggestion
We had some discussion about oversampling (maybe 2 years ago), and I think it was mentioned that something like you suggest might be possible in Csound 7.
IIRC Victor mentioned that Stevan had something in the works :-)

søn. 9. jan. 2022 kl. 10:33 skrev Anders Genell <anders.genell@gmail.com>:
I might have asked something similar long ago, but I don’t remember what the answer was, and perhaps things have changed for upcoming 7.0 so here I go again:

Would it be possible to add functionality for allowing a different sr in user opcodes?

The reason I ask is that I have a use case where I would like to be able to use some fairly steep, narrow band filters for low frequencies, and it’s difficult to get stable results without reducing sampling frequency. I was thinking that a first implementation could be a simple 2, 4, 8 etc factor reduction of sr.
… perhaps this could be done using an externally generated impulse response and a straight up multiplication using arrays and fft opcodes?

Regards,
Anders

Date2022-01-09 14:14
FromVictor Lazzarini
SubjectRe: [Csnd-dev] [EXTERNAL] [Csnd-dev] Feature suggestion
Potentially it's already possible if you run the same filter twice or more times over the same input data using a loop and then taking the single last output of the filter.

That's a specific type of oversampling, double, triple, quadruple sampling. The filter parameters will need to be scaled accordingly because of the higher sr.

Also since Csound manipulates signals directly, any oversampling should be possible "by hand" too, implementing the upsampling and downsampling yourself,
and possibly the filter if needed. It won't be as efficient as in C, but it will work. 

I thought Oeyvind had worked on this before, but maybe it was something else. I would need to study oversampling myself before I ventured an example beyond the simple case of double etc sampling 

The whole area of UDOs needs a redesign to incorporate upsampling but it's possible and in our roadmap.

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 9 Jan 2022, at 09:33, Anders Genell  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.
> 
> I might have asked something similar long ago, but I don’t remember what the answer was, and perhaps things have changed for upcoming 7.0 so here I go again:
> 
> Would it be possible to add functionality for allowing a different sr in user opcodes?
> 
> The reason I ask is that I have a use case where I would like to be able to use some fairly steep, narrow band filters for low frequencies, and it’s difficult to get stable results without reducing sampling frequency. I was thinking that a first implementation could be a simple 2, 4, 8 etc factor reduction of sr.
> … perhaps this could be done using an externally generated impulse response and a straight up multiplication using array

Date2022-01-09 20:13
FromOeyvind Brandtsegg
SubjectRe: [Csnd-dev] [EXTERNAL] [Csnd-dev] Feature suggestion
Yes, I made a UDO for oversampling (posted at the list here I think sometime around august 2020), and at the time you mentioned it might become much easier in Csound7. If needed perhaps my UDO design could be modified to do "undersampling" too. Skipping every second sample and writing the result to an array, then simply process that as if it is audio using any Csound opcode, and then upsampling by stuffing in zeros and filtering. Then again, if local sr is planned as a feature of Cs7, it would not be necessary to make the UDOs :-)

søn. 9. jan. 2022 kl. 15:14 skrev Victor Lazzarini <Victor.Lazzarini@mu.ie>:
Potentially it's already possible if you run the same filter twice or more times over the same input data using a loop and then taking the single last output of the filter.

That's a specific type of oversampling, double, triple, quadruple sampling. The filter parameters will need to be scaled accordingly because of the higher sr.

Also since Csound manipulates signals directly, any oversampling should be possible "by hand" too, implementing the upsampling and downsampling yourself,
and possibly the filter if needed. It won't be as efficient as in C, but it will work.

I thought Oeyvind had worked on this before, but maybe it was something else. I would need to study oversampling myself before I ventured an example beyond the simple case of double etc sampling

The whole area of UDOs needs a redesign to incorporate upsampling but it's possible and in our roadmap.

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 9 Jan 2022, at 09:33, Anders Genell <anders.genell@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.
>
> I might have asked something similar long ago, but I don’t remember what the answer was, and perhaps things have changed for upcoming 7.0 so here I go again:
>
> Would it be possible to add functionality for allowing a different sr in user opcodes?
>
> The reason I ask is that I have a use case where I would like to be able to use some fairly steep, narrow band filters for low frequencies, and it’s difficult to get stable results without reducing sampling frequency. I was thinking that a first implementation could be a simple 2, 4, 8 etc factor reduction of sr.
> … perhaps this could be done using an externally generated impulse response and a straight up multiplication using arrays and fft opcodes?
>
> Regards,
> Anders