Csound Csound-dev Csound-tekno Search About

[Csnd] How shift pitch continuously?

Date2017-09-20 04:51
Fromboleszek
Subject[Csnd] How shift pitch continuously?
Hello Csound community,

As a new user I realize this may be a simple question with a simple answer,
but how can I make a continuous pitch sweep? If I run the following score
using a simple oscillator instrument (and a short duration) to raise the
pitch from 440Hz to 470Hz I get a horrible glitchy sound because the
instrument is accenting every single pitch increment.

f1 0 1024 10 1

;  start drur  amp      fq    tbl
i1  0    0.02 10000    440    1
i1  +    .      .           441    1
i1  +    .      .           442    1
i1  +    .      .           443    1
i1  +    .      .           444    1
i1  +    .      .           445    1
i1  +    .      .           446    1
i1  +    .      .           447    1
i1  +    .      .           448    1
i1  +    .      .           449    1
i1  +    .      .           450    1
i1  +    .      .           451    1
i1  +    .      .           452    1
i1  +    .      .           453    1
i1  +    .      .           454    1
i1  +    .      .           455    1
i1  +    .      .           456    1
i1  +    .      .           457    1
i1  +    .      .           458    1
i1  +    .      .           459    1
i1  +    .      .           460    1
i1  +    .      .           461    1
i1  +    .      .           462    1
i1  +    .      .           463    1
i1  +    .      .           464    1
i1  +    .      .           465    1
i1  +    .      .           466    1
i1  +    .      .           467    1
i1  +    .      .           468    1
i1  +    .      .           469    1
i1  +    .      .           470    1

I’ve tried to shorten the duration thinking that maybe it was just too
coarse, but that seemed to make the sound uglier. I am treating dur as a
sort of sampling rate here, which I realize is not how this is designed to
work.
I’m working on a fun project where I ultimately want to use neural data
(sampled at 3kHz) to control the pitch continuously, but at this point I
just want to be able to smoothly shift the pitch of a simple sinusoid.

Any help would be greatly appreciated!

Thanks,

Bo



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2017-09-20 06:21
FromForrest Curo
SubjectRe: [Csnd] How shift pitch continuously?
Use a k-rate (or even a-rate) variable to control the pitch of an oscillator. Put them into an instrument that (fairly) smoothly changes that variable. In the score, use one p-field as a starting point, another as an end point for the change, maybe a third to set the rate or the time elapsed from start to finish.... There are many ways possible.

If you aren't too concerned about specifying the curve precisely, just want a smooth change... there's an opcode specifically for that (but it's fallen out of my head at the moment. Not 'ramp', but a similar term.)

On Tue, Sep 19, 2017 at 8:51 PM, boleszek <boleszeko@gmail.com> wrote:
Hello Csound community,

As a new user I realize this may be a simple question with a simple answer,
but how can I make a continuous pitch sweep? If I run the following score
using a simple oscillator instrument (and a short duration) to raise the
pitch from 440Hz to 470Hz I get a horrible glitchy sound because the
instrument is accenting every single pitch increment.

f1 0 1024 10 1

;  start drur  amp      fq    tbl
i1  0    0.02 10000    440    1
i1  +    .      .           441    1
i1  +    .      .           442    1
i1  +    .      .           443    1
i1  +    .      .           444    1
i1  +    .      .           445    1
i1  +    .      .           446    1
i1  +    .      .           447    1
i1  +    .      .           448    1
i1  +    .      .           449    1
i1  +    .      .           450    1
i1  +    .      .           451    1
i1  +    .      .           452    1
i1  +    .      .           453    1
i1  +    .      .           454    1
i1  +    .      .           455    1
i1  +    .      .           456    1
i1  +    .      .           457    1
i1  +    .      .           458    1
i1  +    .      .           459    1
i1  +    .      .           460    1
i1  +    .      .           461    1
i1  +    .      .           462    1
i1  +    .      .           463    1
i1  +    .      .           464    1
i1  +    .      .           465    1
i1  +    .      .           466    1
i1  +    .      .           467    1
i1  +    .      .           468    1
i1  +    .      .           469    1
i1  +    .      .           470    1

I’ve tried to shorten the duration thinking that maybe it was just too
coarse, but that seemed to make the sound uglier. I am treating dur as a
sort of sampling rate here, which I realize is not how this is designed to
work.
I’m working on a fun project where I ultimately want to use neural data
(sampled at 3kHz) to control the pitch continuously, but at this point I
just want to be able to smoothly shift the pitch of a simple sinusoid.

Any help would be greatly appreciated!

Thanks,

Bo



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2017-09-20 07:19
Fromboleszek
SubjectRe: [Csnd] How shift pitch continuously?
Thanks for the suggestions.

I'm learning about k-rate and a-rate, but I'm not sure that will help me
with my ultimate goal. I'm looking for a way to control the pitch of an
oscillator (or any tonal instrument for that matter) with arbitrary
waveforms. I'm a neuroscientist at the University of Chicago, and I have
electrical signals that I've recorded from rat brains that I would like to
sonify. These signals alternate between gamma band (60-100Hz) and beta band
(15-30Hz) oscillations so I was hoping to use the signal's instantaneous
frequency as an input to control the pitch. I also plan on collaborating
with an EEG lab in my building to allow people to hear their own brain waves
in real time.

Any suggestions on how to get an arbitrary waveform to smoothly control a
parameter like pitch?

Thanks a lot!

B

P.S. When I do eventual sonify the neural data I will make a little website
for it and post the link here!



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2017-09-20 07:50
FromIain McCurdy
SubjectRe: [Csnd] How shift pitch continuously?

Maybe you can load your recorded electrical signals in as audio (GEN01) or as a list of values (GEN02, GEN23). There are any number of ways in which these could then be read by an oscillator in an instrument. Here is a simple example where the pitch signal is created using GEN05.


<CsoundSynthesizer>
<CsOptions>
-odac -d
</CsOptions>
<CsInstruments>
0dbfs = 1
giDuration = 5
giPitchWave ftgen 0, 0, giDuration*sr, -5, 220, 2.5*sr, 440, 2.5*sr, 220
instr 1
 p3 = giDuration
 aPitch poscil 1, 1/p3, giPitchWave
 aSig poscil 0.5, aPitch
  out aSig
endin
</CsInstruments>
<CsScore>
i 1 0 0.1
</CsScore>
</CsoundSynthesizer>






From: A discussion list for users of Csound <CSOUND@LISTSERV.HEANET.IE> on behalf of boleszek <boleszeko@GMAIL.COM>
Sent: 20 September 2017 06:19
To: CSOUND@LISTSERV.HEANET.IE
Subject: Re: [Csnd] How shift pitch continuously?
 
Thanks for the suggestions.

I'm learning about k-rate and a-rate, but I'm not sure that will help me
with my ultimate goal. I'm looking for a way to control the pitch of an
oscillator (or any tonal instrument for that matter) with arbitrary
waveforms. I'm a neuroscientist at the University of Chicago, and I have
electrical signals that I've recorded from rat brains that I would like to
sonify. These signals alternate between gamma band (60-100Hz) and beta band
(15-30Hz) oscillations so I was hoping to use the signal's instantaneous
frequency as an input to control the pitch. I also plan on collaborating
with an EEG lab in my building to allow people to hear their own brain waves
in real time.

Any suggestions on how to get an arbitrary waveform to smoothly control a
parameter like pitch?

Thanks a lot!

B

P.S. When I do eventual sonify the neural data I will make a little website
for it and post the link here!



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html



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

Date2017-09-20 08:18
Fromboleszek
SubjectRe: [Csnd] How shift pitch continuously?
GEN23 reads numeric values from text files so I can just save my data as text
files! Thanks, I think I'm on the right track now!

Bo



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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