Csound Csound-dev Csound-tekno Search About

[Csnd] pitch shifting

Date2022-06-02 17:12
FromAnders Genell
Subject[Csnd] pitch shifting
Dear sounders!
I am trying to mimic a recorded sound by creating an impulse response based on the recording and convolving white noise. The recording is broadband in its nature, but with some tone-like characters. The synthesis works as well as can be expected, but now I want to be able to pitch shift the resulting sound. Since I don't really use oscillators, I wonder if there are some simple tricks to apply? I tried pvscale, but I get comb filter-like artefacts that I really would like to avoid. One idea I have is to read the impulse response with diskin using pitch shift, and writing the result to a table (with e.g. tabw) and then to use dconv based on that table to get the result. The IR is about 0.5 seconds, so I suppose it should be ok, but it feels a bit cumbersome. I guess I could also do something clever with doppler to have something like a continuous approaching or receding sound...

Regards,
Anders

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

Date2022-06-02 17:51
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] pitch shifting
You can try a delay line pitch shifter. Look at Russell Pinkerton's chapter in the Csound book (2000).

Prof. Victor Lazzarini
Maynooth University
Ireland

On 2 Jun 2022, at 17:13, 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.

Dear sounders!
I am trying to mimic a recorded sound by creating an impulse response based on the recording and convolving white noise. The recording is broadband in its nature, but with some tone-like characters. The synthesis works as well as can be expected, but now I want to be able to pitch shift the resulting sound. Since I don't really use oscillators, I wonder if there are some simple tricks to apply? I tried pvscale, but I get comb filter-like artefacts that I really would like to avoid. One idea I have is to read the impulse response with diskin using pitch shift, and writing the result to a table (with e.g. tabw) and then to use dconv based on that table to get the result. The IR is about 0.5 seconds, so I suppose it should be ok, but it feels a bit cumbersome. I guess I could also do something clever with doppler to have something like a continuous approaching or receding sound...

Regards,
Anders

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

Date2022-06-02 17:59
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] pitch shifting
Also alternatively you can write the sound to a function table and read it with temposcal (or mincer). That uses time-domain resampling instead of frequency-domain pitch shifting.

You can do this in a streaming fashion by using tablew to write the table. Of course there will be some latency, but I suppose you're not worried about it.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 2 Jun 2022, at 17:13, 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.

Dear sounders!
I am trying to mimic a recorded sound by creating an impulse response based on the recording and convolving white noise. The recording is broadband in its nature, but with some tone-like characters. The synthesis works as well as can be expected, but now I want to be able to pitch shift the resulting sound. Since I don't really use oscillators, I wonder if there are some simple tricks to apply? I tried pvscale, but I get comb filter-like artefacts that I really would like to avoid. One idea I have is to read the impulse response with diskin using pitch shift, and writing the result to a table (with e.g. tabw) and then to use dconv based on that table to get the result. The IR is about 0.5 seconds, so I suppose it should be ok, but it feels a bit cumbersome. I guess I could also do something clever with doppler to have something like a continuous approaching or receding sound...

Regards,
Anders

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

Date2022-06-02 18:56
FromAnders Genell
SubjectRe: [Csnd] [EXTERNAL] [Csnd] pitch shifting
Thank you, Victor!
I shall explore both these avenues, though a priori I am partial to the temposcal solution.

Regards,
Anders

tors 2 juni 2022 kl. 18:59 skrev Victor Lazzarini <Victor.Lazzarini@mu.ie>:
Also alternatively you can write the sound to a function table and read it with temposcal (or mincer). That uses time-domain resampling instead of frequency-domain pitch shifting.

You can do this in a streaming fashion by using tablew to write the table. Of course there will be some latency, but I suppose you're not worried about it.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 2 Jun 2022, at 17:13, 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.

Dear sounders!
I am trying to mimic a recorded sound by creating an impulse response based on the recording and convolving white noise. The recording is broadband in its nature, but with some tone-like characters. The synthesis works as well as can be expected, but now I want to be able to pitch shift the resulting sound. Since I don't really use oscillators, I wonder if there are some simple tricks to apply? I tried pvscale, but I get comb filter-like artefacts that I really would like to avoid. One idea I have is to read the impulse response with diskin using pitch shift, and writing the result to a table (with e.g. tabw) and then to use dconv based on that table to get the result. The IR is about 0.5 seconds, so I suppose it should be ok, but it feels a bit cumbersome. I guess I could also do something clever with doppler to have something like a continuous approaching or receding sound...

Regards,
Anders

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

Date2022-06-02 23:10
FromOeyvind Brandtsegg
SubjectRe: [Csnd] pitch shifting
Hi,
The liveconvolver csd at https://github.com/Oeyvind/liveconvolver has functionality for pitch shifting the IR. It is similar to what you describe in reading the sound faster/slower and then writing to a new IR. The pitching happens around line 470.
Øyvind

tor. 2. jun. 2022, 6:12 p.m. skrev Anders Genell <anders.genell@gmail.com>:
Dear sounders!
I am trying to mimic a recorded sound by creating an impulse response based on the recording and convolving white noise. The recording is broadband in its nature, but with some tone-like characters. The synthesis works as well as can be expected, but now I want to be able to pitch shift the resulting sound. Since I don't really use oscillators, I wonder if there are some simple tricks to apply? I tried pvscale, but I get comb filter-like artefacts that I really would like to avoid. One idea I have is to read the impulse response with diskin using pitch shift, and writing the result to a table (with e.g. tabw) and then to use dconv based on that table to get the result. The IR is about 0.5 seconds, so I suppose it should be ok, but it feels a bit cumbersome. I guess I could also do something clever with doppler to have something like a continuous approaching or receding sound...

Regards,
Anders

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

Date2022-07-21 20:22
FromJonathan Cohen
Subject[Csnd] outvalue callback behavior question

Dear CSound Folks,

I have a question about the expected behavior of the outvalue callback. I'm using the CSound version 6.16 library via Python 3.83 under Windows 10.

The callback is working fine, but if I use it at k-rate, there seems to be an extra invocation of it at init time. For example, if in the python code I set up the callback with:

cs = ctcsound.Csound()
...
cs.setOutputChannelCallback(out_value_callback)
...

def out_value_callback(self, _cs_ptr, channel_name, channel_value_p, _channel_type_p):

    double_p = ctypes.POINTER(ctypes.c_double)

    channel_value_ptr = ctypes.cast(channel_value_p, double_p)

    bs = bytearray(channel_name)

    name = bs.decode()

    print(f"out value callback {name} {channel_value_ptr.contents.value}")

and the CSound code looks something like:

instr 1
...
k_release init 0
...

k_release = release()
if k_release == 1 then
    outvalue("instrument 1 ends", k_release)
endif
...
endin

Then out_value_callback will be triggered twice, once when the instr begins and once when the instr ends.  The output results in Python will be:

out value callback instrument 1 ends 0
out value callback instrument 1 ends 1

My workaround is to ignore the callback when the channel value == 0, but I was wondering whether the invocation of the callback at init time was expected behavior, or if not, what I have done to trigger it unintentionally.

Thank you very much.

Cheers,

- j






Date2022-07-21 22:59
FromEduardo Moguillansky
SubjectRe: [Csnd] outvalue callback behavior question

Looking at the code, there is a hardcoded invocation of the callback at init time together with the comment "send output now for use during i-pass". I don't think that you can avoid it. 

On 21.07.22 21:22, Jonathan Cohen wrote:

Dear CSound Folks,

I have a question about the expected behavior of the outvalue callback. I'm using the CSound version 6.16 library via Python 3.83 under Windows 10.

The callback is working fine, but if I use it at k-rate, there seems to be an extra invocation of it at init time. For example, if in the python code I set up the callback with:

cs = ctcsound.Csound()
...
cs.setOutputChannelCallback(out_value_callback)
...

def out_value_callback(self, _cs_ptr, channel_name, channel_value_p, _channel_type_p):

    double_p = ctypes.POINTER(ctypes.c_double)

    channel_value_ptr = ctypes.cast(channel_value_p, double_p)

    bs = bytearray(channel_name)

    name = bs.decode()

    print(f"out value callback {name} {channel_value_ptr.contents.value}")

and the CSound code looks something like:

instr 1
...
k_release init 0
...

k_release = release()
if k_release == 1 then
    outvalue("instrument 1 ends", k_release)
endif
...
endin

Then out_value_callback will be triggered twice, once when the instr begins and once when the instr ends.  The output results in Python will be:

out value callback instrument 1 ends 0
out value callback instrument 1 ends 1

My workaround is to ignore the callback when the channel value == 0, but I was wondering whether the invocation of the callback at init time was expected behavior, or if not, what I have done to trigger it unintentionally.

Thank you very much.

Cheers,

- j





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

Date2022-07-22 21:34
FromJonathan Cohen
SubjectRe: [Csnd] outvalue callback behavior question

Thank you Eduardo--much appreciated. (Will try looking at the source next time I have a question.)

Cheers,

- j



Looking at the code, there is a hardcoded invocation of the callback at init time together with the comment "send output now for use during i-pass". I don't think that you can avoid it. 

On 21.07.22 21:22, Jonathan Cohen wrote:

Dear CSound Folks,

I have a question about the expected behavior of the outvalue callback. I'm using the CSound version 6.16 library via Python 3.83 under Windows 10.

The callback is working fine, but if I use it at k-rate, there seems to be an extra invocation of it at init time. For example, if in the python code I set up the callback with:

cs = ctcsound.Csound()
...
cs.setOutputChannelCallback(out_value_callback)
...

def out_value_callback(self, _cs_ptr, channel_name, channel_value_p, _channel_type_p):

    double_p = ctypes.POINTER(ctypes.c_double)

    channel_value_ptr = ctypes.cast(channel_value_p, double_p)

    bs = bytearray(channel_name)

    name = bs.decode()

    print(f"out value callback {name} {channel_value_ptr.contents.value}")

and the CSound code looks something like:

instr 1
...
k_release init 0
...

k_release = release()
if k_release == 1 then
    outvalue("instrument 1 ends", k_release)
endif
...
endin

Then out_value_callback will be triggered twice, once when the instr begins and once when the instr ends.  The output results in Python will be:

out value callback instrument 1 ends 0
out value callback instrument 1 ends 1

My workaround is to ignore the callback when the channel value == 0, but I was wondering whether the invocation of the callback at init time was expected behavior, or if not, what I have done to trigger it unintentionally.

Thank you very much.

Cheers,

- j





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