Csound Csound-dev Csound-tekno Search About

[Csnd] note/pitch quantisation to scale

Date2021-12-30 21:23
From"Jeanette C."
Subject[Csnd] note/pitch quantisation to scale
Hey hey,
I'd like to "quantise" both MIDI notes and frequencies to musical scales. I 
suppose cpstun is a tool for the latter.

But is there a good realtime capable method to quantise MIDI notes to a MIDI 
note scale? I thought about a table lookup with 127 elements, which is created 
from some kind of short description.

Does anyone have ideas on these topics or a good pointer? Most of my research 
discovered such features in DAWs.

Best wishes and many thanks,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

I believe
We all have one true love
Somewhere in this world <3
(Britney Spears)

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

Date2021-12-31 12:07
FromJohn ff
SubjectRe: [Csnd] note/pitch quantisation to scale
Not sure I understand what you need but a lookup table to take MIDI number to frequency is fast and simple.

If on the other hand you have a frequency and you want to quantise it to a scale then a table   can be searched to find the nearest value, either linear search or binary.

On 30 Dec 2021, at 21:23, "Jeanette C." <julien@mail.upb.de> wrote:
Hey hey,
I'd like to "quantise" both MIDI notes and frequencies to musical scales. I
suppose cpstun is a tool for the latter.

But is there a good realtime capable method to quantise MIDI notes to a MIDI
note scale? I thought about a table lookup with 127 elements, which is created
from some kind of short description.

Does anyone have ideas on these topics or a good pointer? Most of my research
discovered such features in DAWs.

Best wishes and many thanks,

Jeanette

Date2021-12-31 12:13
Fromjoachim heintz
SubjectRe: [Csnd] note/pitch quantisation to scale
how would you do this search ("either linear search or binary")?


On 31/12/2021 13:07, John ff wrote:
> Not sure I understand what you need but a lookup table to take MIDI 
> number to frequency is fast and simple.
> 
> If on the other hand you have a frequency and you want to quantise it to 
> a scale then a table   can be searched to find the nearest value, either 
> linear search or binary.
> 
> Get TypeApp for Android 
> On 30 Dec 2021, at 21:23, "Jeanette C."  > wrote:
> 
>     Hey hey,
>     I'd like to "quantise" both MIDI notes and frequencies to musical scales. I
>     suppose cpstun is a tool for the latter.
> 
>     But is there a good realtime capable method to quantise MIDI notes to a MIDI
>     note scale? I thought about a table lookup with 127 elements, which is created
>     from some kind of short description.
> 
>     Does anyone have ideas on these topics or a good pointer? Most of my research
>     discovered such features in DAWs.
> 
>     Best wishes and many thanks,
> 
>     Jeanette
> 
> 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

Date2021-12-31 13:45
FromForrest Curo
SubjectRe: [Csnd] note/pitch quantisation to scale
Not knowing about cpstun, I just calculated:
ifreq = girats[giscale[idegree]] * 2 ^ ioct * gifund ; NOT 'ifreq mtof ikey'
where 'girats' was an array of just-tuning ratios for one octave (one for each 'idegree' of a scale), and ioct was the octave of the midi note being played.

The degree was midi % 12, the octave (int (midi/12)) -- Or int(midi % 8), if I'd simplified a scale down to 7 degrees mapped to the white keys, say. (Convenient for a pianistically-impaired player like me):  gidegree[] fillarray 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6

Any help?


On Fri, Dec 31, 2021 at 4:13 AM joachim heintz <jh@joachimheintz.de> wrote:
how would you do this search ("either linear search or binary")?


On 31/12/2021 13:07, John ff wrote:
> Not sure I understand what you need but a lookup table to take MIDI
> number to frequency is fast and simple.
>
> If on the other hand you have a frequency and you want to quantise it to
> a scale then a table   can be searched to find the nearest value, either
> linear search or binary.
>
> Get TypeApp for Android <http://www.typeapp.com/r>
> On 30 Dec 2021, at 21:23, "Jeanette C." <julien@mail.upb.de
> <mailto:julien@mail.upb.de>> wrote:
>
>     Hey hey,
>     I'd like to "quantise" both MIDI notes and frequencies to musical scales. I
>     suppose cpstun is a tool for the latter.
>
>     But is there a good realtime capable method to quantise MIDI notes to a MIDI
>     note scale? I thought about a table lookup with 127 elements, which is created
>     from some kind of short description.
>
>     Does anyone have ideas on these topics or a good pointer? Most of my research
>     discovered such features in DAWs.
>
>     Best wishes and many thanks,
>
>     Jeanette
>
> Csound mailing list Csound@listserv.heanet.ie
> <mailto:Csound@listserv.heanet.ie>
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports to
> https://github.com/csound/csound/issues
> <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

Date2021-12-31 13:55
From"Jeanette C."
SubjectRe: [Csnd] note/pitch quantisation to scale
Thanks all. I'm going with the lookup table for MIDI notes.

For pitches I'm slowly leaning towards one solution, but it will be limited to 
the western scale. It's not completely worked out yet, but:
iPch = cpspch(iFreqInHz)
iOct = int(iPch)
iOriginalDegree = frac(iPch)
iQuantisedNote = int(iOriginalDegree * 100) ; (ranges 0-11.x)
Then use a lookup table, create a new pch pitch and convert back to cps. Does 
that sound reasonable?

Best wishes,

Jeanette

Dec 31 2021, Forrest Curo has written:

> Not knowing about cpstun, I just calculated:
> ifreq = girats[giscale[idegree]] * 2 ^ ioct * gifund ; NOT 'ifreq mtof ikey'
> where 'girats' was an array of just-tuning ratios for one octave (one for
> each 'idegree' of a scale), and ioct was the octave of the midi note being
> played.
>
> The degree was midi % 12, the octave (int (midi/12)) -- Or int(midi % 8),
> if I'd simplified a scale down to 7 degrees mapped to the white keys, say.
> (Convenient for a pianistically-impaired player like me):  gidegree[]
> fillarray 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6
>
> Any help?
>
>
> On Fri, Dec 31, 2021 at 4:13 AM joachim heintz  wrote:
>
>> how would you do this search ("either linear search or binary")?
>>
>>
>> On 31/12/2021 13:07, John ff wrote:
>>> Not sure I understand what you need but a lookup table to take MIDI
>>> number to frequency is fast and simple.
>>>
>>> If on the other hand you have a frequency and you want to quantise it to
>>> a scale then a table   can be searched to find the nearest value, either
>>> linear search or binary.
>>>
>>> Get TypeApp for Android 
>>> On 30 Dec 2021, at 21:23, "Jeanette C." >> > wrote:
>>>
>>>     Hey hey,
>>>     I'd like to "quantise" both MIDI notes and frequencies to musical
>> scales. I
>>>     suppose cpstun is a tool for the latter.
>>>
>>>     But is there a good realtime capable method to quantise MIDI notes
>> to a MIDI
>>>     note scale? I thought about a table lookup with 127 elements, which
>> is created
>>>     from some kind of short description.
>>>
>>>     Does anyone have ideas on these topics or a good pointer? Most of my
>> research
>>>     discovered such features in DAWs.
>>>
>>>     Best wishes and many thanks,
>>>
>>>     Jeanette
>>>
>>> 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
>

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Do you even know what I like
Just what I'm living for,
What I adore <3
(Britney Spears)

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

Date2021-12-31 15:45
FromDave Seidel
SubjectRe: [Csnd] note/pitch quantisation to scale
The method I've been using for a few years in the Implication Organ, which supports switching between multiple tunings, is to define each tuning using GEN51:

 ; LMY WTP
giWTP = ftgen(201, 0, 128, -51,
              12, 2, 297.989, 63,
              1, 567/512, 9/8, 147/128, 21/16, 1323/1024, 189/128, 3/2, 49/32, 7/4, 441/256, 63/32, 2)

and then use tablekt to convert incoming MIDI notes into frequencies

kfreq = tablekt(knote, gk_tuning)

This has been working quite well for me. Complete source code here: https://github.com/DaveSeidel/music-src/tree/master/implication-organ

On Thu, Dec 30, 2021 at 4:22 PM Jeanette C. <julien@mail.upb.de> wrote:
Hey hey,
I'd like to "quantise" both MIDI notes and frequencies to musical scales. I
suppose cpstun is a tool for the latter.

But is there a good realtime capable method to quantise MIDI notes to a MIDI
note scale? I thought about a table lookup with 127 elements, which is created
from some kind of short description.

Does anyone have ideas on these topics or a good pointer? Most of my research
discovered such features in DAWs.

Best wishes and many thanks,

Jeanette

--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

I believe
We all have one true love
Somewhere in this world <3
(Britney Spears)

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

Date2021-12-31 15:49
FromDave Seidel
SubjectRe: [Csnd] note/pitch quantisation to scale
To be clear, the variable "gk_tuning" points to one of the GEN51-generated tables of frequency values, and "knote" in the MIDI notes number.

On Fri, Dec 31, 2021 at 10:45 AM Dave Seidel <dave.seidel@gmail.com> wrote:
The method I've been using for a few years in the Implication Organ, which supports switching between multiple tunings, is to define each tuning using GEN51:

 ; LMY WTP
giWTP = ftgen(201, 0, 128, -51,
              12, 2, 297.989, 63,
              1, 567/512, 9/8, 147/128, 21/16, 1323/1024, 189/128, 3/2, 49/32, 7/4, 441/256, 63/32, 2)

and then use tablekt to convert incoming MIDI notes into frequencies

kfreq = tablekt(knote, gk_tuning)

This has been working quite well for me. Complete source code here: https://github.com/DaveSeidel/music-src/tree/master/implication-organ

On Thu, Dec 30, 2021 at 4:22 PM Jeanette C. <julien@mail.upb.de> wrote:
Hey hey,
I'd like to "quantise" both MIDI notes and frequencies to musical scales. I
suppose cpstun is a tool for the latter.

But is there a good realtime capable method to quantise MIDI notes to a MIDI
note scale? I thought about a table lookup with 127 elements, which is created
from some kind of short description.

Does anyone have ideas on these topics or a good pointer? Most of my research
discovered such features in DAWs.

Best wishes and many thanks,

Jeanette

--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

I believe
We all have one true love
Somewhere in this world <3
(Britney Spears)

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