Csound Csound-dev Csound-tekno Search About

MIDI controller for incremental change

Date2016-12-29 21:41
From"d.vyd@outlook.com"
SubjectMIDI controller for incremental change

Hi folks,


Both in my traditional DAW and in the Csound examples I've seen so far, MIDI is used to send an absolute value for a note parameter (e.g. oscillator frequency). I have an external controller with the standard knobs and sliders that send whole numbers from 0 to 127. The only way I can think of such controls permitting me to smoothly move between 0hz and 20khz would be to interpret the value as an increment or acceleration. So, 64 would keep the sound steady, 65 would increase the frequency extremely slowly, and 127 would increase the frequency extremely quickly. Values below 64 would move in the opposite direction. I'm guessing someone has already implemented a system like this--if so, is the code available somewhere? If not, any pointers? I'm guessing krate determines how quickly MIDI data is processed and therefore would affect the acceleration?


Thank you,

d. vyd





Date2016-12-29 23:30
FromMichael Gogins
SubjectRe: MIDI controller for incremental change
You can filter or smooth the MIDI numbers. That will be easier to deal
with than using a rate of change, because a sharp change in the rate
of change will also be audible. Here's a example:

  instr 1
iCps      cpsmidi ;read in midi pitch in cycles-per-second
iAmp      ampmidi 1; read in note velocity - re-range to be from 0 to 1
kVol      ctrl7   1,1,0,1; read in controller 1, channel 1. Re-range
to be from 0 to 1
kPortTime linseg  0,0.001,0.01; create a value that quickly ramps up to 0.01
kVol      portk   kVol, kPortTime; create a new version of kVol that
has been filtered (smoothed) using portk
aVol      interp  kVol; create an a-rate version of kVol. Use
intepolation to smooth this signal even further
aSig      poscil  iAmp*aVol, iCps, giSine
          out     aSig
  endin

Regards,
Mik

-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Thu, Dec 29, 2016 at 4:41 PM, d.vyd@outlook.com  wrote:
> Hi folks,
>
>
> Both in my traditional DAW and in the Csound examples I've seen so far, MIDI
> is used to send an absolute value for a note parameter (e.g. oscillator
> frequency). I have an external controller with the standard knobs and
> sliders that send whole numbers from 0 to 127. The only way I can think of
> such controls permitting me to smoothly move between 0hz and 20khz would be
> to interpret the value as an increment or acceleration. So, 64 would keep
> the sound steady, 65 would increase the frequency extremely slowly, and 127
> would increase the frequency extremely quickly. Values below 64 would move
> in the opposite direction. I'm guessing someone has already implemented a
> system like this--if so, is the code available somewhere? If not, any
> pointers? I'm guessing krate determines how quickly MIDI data is processed
> and therefore would affect the acceleration?
>
>
> Thank you,
>
> d. vyd
>
>
>
>
> 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

Date2016-12-30 01:35
FromAndrea Strappa
SubjectRe: MIDI controller for incremental change
As I understand it, mr. d. vyd, gen16 can do for you:



-odac -M0 -B4096 -b400 --midi-velocity-amp=4 --midi-key-cps=5 
;-+rtmidi=winMM


         sr = 44100
         ksmps = 5
         0dbfs = 1
         nchnls = 2
         massign 0, 1
         instr 1
iamp        = p4
ifreq        = p5
         ctrlinit 1, 1, 64 ;sets the initial value of MIDI ctrl on the 
middle
kndx        midictrl 1, 0, 1024 ;midictrl cc1 read table f1
kfun        table kndx, 10, 0
kfun        = kfun ;* 1.75 + 2
         printk .1, kfun
kenv        madsr .02, .2, iamp, .3
asig        poscil kenv, ifreq*kfun
         outs asig*.2, asig*.2
         endin


f0 z
;GEN 16 (pp. 2934-36 Csound6.05_manual.pdf)
;        -2octaves        Tone            +2octaves
         ;val dur type        val dur type        val
f10 0 1024 -16     .25 512 -7        1 512 7            4.042
e





Il 30/12/2016 00:30, Michael Gogins ha scritto:
> You can filter or smooth the MIDI numbers. That will be easier to deal
> with than using a rate of change, because a sharp change in the rate
> of change will also be audible. Here's a example:
>
>    instr 1
> iCps      cpsmidi ;read in midi pitch in cycles-per-second
> iAmp      ampmidi 1; read in note velocity - re-range to be from 0 to 1
> kVol      ctrl7   1,1,0,1; read in controller 1, channel 1. Re-range
> to be from 0 to 1
> kPortTime linseg  0,0.001,0.01; create a value that quickly ramps up to 0.01
> kVol      portk   kVol, kPortTime; create a new version of kVol that
> has been filtered (smoothed) using portk
> aVol      interp  kVol; create an a-rate version of kVol. Use
> intepolation to smooth this signal even further
> aSig      poscil  iAmp*aVol, iCps, giSine
>            out     aSig
>    endin
>
> Regards,
> Mik
>
> -----------------------------------------------------
> Michael Gogins
> Irreducible Productions
> http://michaelgogins.tumblr.com
> Michael dot Gogins at gmail dot com
>
>
> On Thu, Dec 29, 2016 at 4:41 PM, d.vyd@outlook.com  wrote:
>> Hi folks,
>>
>>
>> Both in my traditional DAW and in the Csound examples I've seen so far, MIDI
>> is used to send an absolute value for a note parameter (e.g. oscillator
>> frequency). I have an external controller with the standard knobs and
>> sliders that send whole numbers from 0 to 127. The only way I can think of
>> such controls permitting me to smoothly move between 0hz and 20khz would be
>> to interpret the value as an increment or acceleration. So, 64 would keep
>> the sound steady, 65 would increase the frequency extremely slowly, and 127
>> would increase the frequency extremely quickly. Values below 64 would move
>> in the opposite direction. I'm guessing someone has already implemented a
>> system like this--if so, is the code available somewhere? If not, any
>> pointers? I'm guessing krate determines how quickly MIDI data is processed
>> and therefore would affect the acceleration?
>>
>>
>> Thank you,
>>
>> d. vyd
>>
>>
>>
>>
>> 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

Date2016-12-30 11:22
FromAndrea Strappa
SubjectRe: MIDI controller for incremental change
Attachmentskport_instable.PNG  
Ok, I get it. Changing the third argument in kPortTime linseg the slider 
mouvement effect is smoothed.

Thank you, Michael. At local 2.30 AM I had misrepresented.

I adapted also manual portk example (it is below), with performance very 
informative.

But my adaptation is a little instable in Windows 10 (.png atthached). Why?

Greetings

Andrea S.



; Select audio/midi flags here according to platform
; Audio out   Audio in
;-odac         ;  -iadc    ;;;RT audio I/O
-odac -M0 -B4096 -b400 --midi-velocity-amp=4 --midi-key-cps=5 
;-+rtmidi=winMM
; For Non-realtime ouput leave only the line below:
; -o portk.wav -W ;;; for file output any platform


sr = 44100
ksmps = 128
nchnls = 1
0dbfs = 1
;Example by Andres Cabrera 2007
FLpanel "Slider", 650, 140, 50, 50
     gkval1, gislider1 FLslider "Watch me", 0, 1, 0, 5, -1, 580, 30, 25, 20
     gkval2, gislider2 FLslider "Move me", 0, 1, 0, 5, -1, 580, 30, 25, 80
     gkhtim, gislider3 FLslider "khtim", 0.1, 1, 0, 6, -1, 30, 100, 610, 10
FLpanelEnd
FLrun
FLsetVal_i 0.1, gislider3 ;set initial time to 0.1
instr 1
iamp    = p4
ifreq    = p5
kval portk gkval2, gkhtim  ; take the value of slider 2 and apply portamento
FLsetVal 1, kval, gislider1  ;set the value of slider 1 to kval
kenv    madsr .05, .1, iamp, .1
asig    poscil kenv*kval, ifreq
out    asig
endin


; Play Instrument #1 for one minute.
i 1 0 60
e








Il 30/12/2016 02:35, Andrea Strappa ha scritto:
> As I understand it, mr. d. vyd, gen16 can do for you:
>
> 
> 
> -odac -M0 -B4096 -b400 --midi-velocity-amp=4 --midi-key-cps=5 
> ;-+rtmidi=winMM
> 
> 
>         sr = 44100
>         ksmps = 5
>         0dbfs = 1
>         nchnls = 2
>         massign 0, 1
>         instr 1
> iamp        = p4
> ifreq        = p5
>         ctrlinit 1, 1, 64 ;sets the initial value of MIDI ctrl on the 
> middle
> kndx        midictrl 1, 0, 1024 ;midictrl cc1 read table f1
> kfun        table kndx, 10, 0
> kfun        = kfun ;* 1.75 + 2
>         printk .1, kfun
> kenv        madsr .02, .2, iamp, .3
> asig        poscil kenv, ifreq*kfun
>         outs asig*.2, asig*.2
>         endin
> 
> 
> f0 z
> ;GEN 16 (pp. 2934-36 Csound6.05_manual.pdf)
> ;        -2octaves        Tone            +2octaves
>         ;val dur type        val dur type        val
> f10 0 1024 -16     .25 512 -7        1 512 7            4.042
> e
> 
> 
>
>
>
> Il 30/12/2016 00:30, Michael Gogins ha scritto:
>> You can filter or smooth the MIDI numbers. That will be easier to deal
>> with than using a rate of change, because a sharp change in the rate
>> of change will also be audible. Here's a example:
>>
>>    instr 1
>> iCps      cpsmidi ;read in midi pitch in cycles-per-second
>> iAmp      ampmidi 1; read in note velocity - re-range to be from 0 to 1
>> kVol      ctrl7   1,1,0,1; read in controller 1, channel 1. Re-range
>> to be from 0 to 1
>> kPortTime linseg  0,0.001,0.01; create a value that quickly ramps up 
>> to 0.01
>> kVol      portk   kVol, kPortTime; create a new version of kVol that
>> has been filtered (smoothed) using portk
>> aVol      interp  kVol; create an a-rate version of kVol. Use
>> intepolation to smooth this signal even further
>> aSig      poscil  iAmp*aVol, iCps, giSine
>>            out     aSig
>>    endin
>>
>> Regards,
>> Mik
>>
>> -----------------------------------------------------
>> Michael Gogins
>> Irreducible Productions
>> http://michaelgogins.tumblr.com
>> Michael dot Gogins at gmail dot com
>>
>>
>> On Thu, Dec 29, 2016 at 4:41 PM, d.vyd@outlook.com 
>>  wrote:
>>> Hi folks,
>>>
>>>
>>> Both in my traditional DAW and in the Csound examples I've seen so 
>>> far, MIDI
>>> is used to send an absolute value for a note parameter (e.g. oscillator
>>> frequency). I have an external controller with the standard knobs and
>>> sliders that send whole numbers from 0 to 127. The only way I can 
>>> think of
>>> such controls permitting me to smoothly move between 0hz and 20khz 
>>> would be
>>> to interpret the value as an increment or acceleration. So, 64 would 
>>> keep
>>> the sound steady, 65 would increase the frequency extremely slowly, 
>>> and 127
>>> would increase the frequency extremely quickly. Values below 64 
>>> would move
>>> in the opposite direction. I'm guessing someone has already 
>>> implemented a
>>> system like this--if so, is the code available somewhere? If not, any
>>> pointers? I'm guessing krate determines how quickly MIDI data is 
>>> processed
>>> and therefore would affect the acceleration?
>>>
>>>
>>> Thank you,
>>>
>>> d. vyd
>>>
>>>
>>>
>>>
>>> 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

Date2016-12-30 14:35
From"d.vyd@outlook.com"
SubjectRe: MIDI controller for incremental change

Michael & Andrea, thank you for your feedback. I hope to investigate this further over the weekend. Michael, I understand your code in concept only. I am not familiar with those opcodes. Interpolation seems prudent, but without some very fine user control, I would not be able to set the pitch (for example) to any particular value, correct? I wonder if a PureData patch handling the rate of change and sending OSC to an instrument interpolating between values may solve this fixation of mine.




From: A discussion list for users of Csound <CSOUND@LISTSERV.HEANET.IE> on behalf of Andrea Strappa <a_strappa@TIN.IT>
Sent: Friday, December 30, 2016 11:22:56 AM
To: CSOUND@LISTSERV.HEANET.IE
Subject: Re: [Csnd] MIDI controller for incremental change
 
Ok, I get it. Changing the third argument in kPortTime linseg the slider
mouvement effect is smoothed.

Thank you, Michael. At local 2.30 AM I had misrepresented.

I adapted also manual portk example (it is below), with performance very
informative.

But my adaptation is a little instable in Windows 10 (.png atthached). Why?

Greetings

Andrea S.

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in
;-odac         ;  -iadc    ;;;RT audio I/O
-odac -M0 -B4096 -b400 --midi-velocity-amp=4 --midi-key-cps=5
;-+rtmidi=winMM
; For Non-realtime ouput leave only the line below:
; -o portk.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 128
nchnls = 1
0dbfs = 1
;Example by Andres Cabrera 2007
FLpanel "Slider", 650, 140, 50, 50
     gkval1, gislider1 FLslider "Watch me", 0, 1, 0, 5, -1, 580, 30, 25, 20
     gkval2, gislider2 FLslider "Move me", 0, 1, 0, 5, -1, 580, 30, 25, 80
     gkhtim, gislider3 FLslider "khtim", 0.1, 1, 0, 6, -1, 30, 100, 610, 10
FLpanelEnd
FLrun
FLsetVal_i 0.1, gislider3 ;set initial time to 0.1
instr 1
iamp    = p4
ifreq    = p5
kval portk gkval2, gkhtim  ; take the value of slider 2 and apply portamento
FLsetVal 1, kval, gislider1  ;set the value of slider 1 to kval
kenv    madsr .05, .1, iamp, .1
asig    poscil kenv*kval, ifreq
out    asig
endin
</CsInstruments>
<CsScore>
; Play Instrument #1 for one minute.
i 1 0 60
e
</CsScore>
</CsoundSynthesizer>






Il 30/12/2016 02:35, Andrea Strappa ha scritto:
> As I understand it, mr. d. vyd, gen16 can do for you:
>
> <CsoundSynthesizer>
> <CsOptions>
> -odac -M0 -B4096 -b400 --midi-velocity-amp=4 --midi-key-cps=5
> ;-+rtmidi=winMM
> </CsOptions>
> <CsInstruments>
>         sr = 44100
>         ksmps = 5
>         0dbfs = 1
>         nchnls = 2
>         massign 0, 1
>         instr 1
> iamp        = p4
> ifreq        = p5
>         ctrlinit 1, 1, 64 ;sets the initial value of MIDI ctrl on the
> middle
> kndx        midictrl 1, 0, 1024 ;midictrl cc1 read table f1
> kfun        table kndx, 10, 0
> kfun        = kfun ;* 1.75 + 2
>         printk .1, kfun
> kenv        madsr .02, .2, iamp, .3
> asig        poscil kenv, ifreq*kfun
>         outs asig*.2, asig*.2
>         endin
> </CsInstruments>
> <CsScore>
> f0 z
> ;GEN 16 (pp. 2934-36 Csound6.05_manual.pdf)
> ;        -2octaves        Tone            +2octaves
>         ;val dur type        val dur type        val
> f10 0 1024 -16     .25 512 -7        1 512 7            4.042
> e
> </CsScore>
> </CsoundSynthesizer>
>
>
>
> Il 30/12/2016 00:30, Michael Gogins ha scritto:
>> You can filter or smooth the MIDI numbers. That will be easier to deal
>> with than using a rate of change, because a sharp change in the rate
>> of change will also be audible. Here's a example:
>>
>>    instr 1
>> iCps      cpsmidi ;read in midi pitch in cycles-per-second
>> iAmp      ampmidi 1; read in note velocity - re-range to be from 0 to 1
>> kVol      ctrl7   1,1,0,1; read in controller 1, channel 1. Re-range
>> to be from 0 to 1
>> kPortTime linseg  0,0.001,0.01; create a value that quickly ramps up
>> to 0.01
>> kVol      portk   kVol, kPortTime; create a new version of kVol that
>> has been filtered (smoothed) using portk
>> aVol      interp  kVol; create an a-rate version of kVol. Use
>> intepolation to smooth this signal even further
>> aSig      poscil  iAmp*aVol, iCps, giSine
>>            out     aSig
>>    endin
>>
>> Regards,
>> Mik
>>
>> -----------------------------------------------------
>> Michael Gogins
>> Irreducible Productions
>> http://michaelgogins.tumblr.com
>> Michael dot Gogins at gmail dot com
>>
>>
>> On Thu, Dec 29, 2016 at 4:41 PM, d.vyd@outlook.com
>> <d.vyd@outlook.com> wrote:
>>> Hi folks,
>>>
>>>
>>> Both in my traditional DAW and in the Csound examples I've seen so
>>> far, MIDI
>>> is used to send an absolute value for a note parameter (e.g. oscillator
>>> frequency). I have an external controller with the standard knobs and
>>> sliders that send whole numbers from 0 to 127. The only way I can
>>> think of
>>> such controls permitting me to smoothly move between 0hz and 20khz
>>> would be
>>> to interpret the value as an increment or acceleration. So, 64 would
>>> keep
>>> the sound steady, 65 would increase the frequency extremely slowly,
>>> and 127
>>> would increase the frequency extremely quickly. Values below 64
>>> would move
>>> in the opposite direction. I'm guessing someone has already
>>> implemented a
>>> system like this--if so, is the code available somewhere? If not, any
>>> pointers? I'm guessing krate determines how quickly MIDI data is
>>> processed
>>> and therefore would affect the acceleration?
>>>
>>>
>>> Thank you,
>>>
>>> d. vyd
>>>
>>>
>>>
>>>
>>> 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