Csound Csound-dev Csound-tekno Search About

[Csnd] Typical Preset Implementation

Date2014-03-27 15:54
FromDominic Melville
Subject[Csnd] Typical Preset Implementation
Hello list, 

Does anyone know of a specific opcode, UDO or workaround that would allow me to implement typical preset behaviour within a Csound instrument? 

I've got an instrument running on an RPI that has physical hardware controls including pots, faders etc. I want to be able to save the states of the parameters controlled by the hardware controls as presets, like one would on a typical synth. 

So for example, I load the basic instrument with it's initial values, play around with the controls tweaking various parameters then once I've got a sound I'm happy with, I want the ability to save and name it for recalling and use later on. 

Any ideas or thoughts would be greatly appreciated, I've dug through the manual, Floss manual, Csound book and searched online but can't find anything outside of CsoundQT or Cabbage at all. Running either isn't really an option for this project.

Thanks 

Dominic 

Date2014-03-27 16:01
FromRory Walsh
SubjectRe: [Csnd] Typical Preset Implementation
You can write the presets to a txt file using foutk, and then read
them in later. I've done this in the past(very distant past!) to save
real-time automation data from my MIDI faders. But sure, it's
definitely possible.

On 27 March 2014 15:54, Dominic Melville  wrote:
> Hello list,
>
> Does anyone know of a specific opcode, UDO or workaround that would allow me
> to implement typical preset behaviour within a Csound instrument?
>
> I've got an instrument running on an RPI that has physical hardware controls
> including pots, faders etc. I want to be able to save the states of the
> parameters controlled by the hardware controls as presets, like one would on
> a typical synth.
>
> So for example, I load the basic instrument with it's initial values, play
> around with the controls tweaking various parameters then once I've got a
> sound I'm happy with, I want the ability to save and name it for recalling
> and use later on.
>
> Any ideas or thoughts would be greatly appreciated, I've dug through the
> manual, Floss manual, Csound book and searched online but can't find
> anything outside of CsoundQT or Cabbage at all. Running either isn't really
> an option for this project.
>
> Thanks
>
> Dominic


Send bugs reports to the Sourceforge bug trackers
csound6:
            https://sourceforge.net/p/csound/tickets/
csound5:
            https://sourceforge.net/p/csound/bugs/
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2014-03-27 20:44
FromRory Walsh
SubjectRe: [Csnd] Typical Preset Implementation
Here's that rather old example I was referring to. It looks like it
will either write the values of the sliders to a text file, or read
the values from the text file and assign, depending on whether
gkStartStop is 1 or not. I'd possibly do it another way if I was doing
it again, but this should still work fine.



-odevaudio -b64 -B4096


; Initialize the global variables.
sr = 44100
ksmps = 64
nchnls = 2

gkscrollbar_1 chnexport "scrollbar_1", 3
gkscrollbar_2 chnexport "scrollbar_2", 3
gkscrollbar_3 chnexport "scrollbar_3", 3
gkscrollbar_4 chnexport "scrollbar_4", 3
gkscrollbar_5 chnexport "scrollbar_5", 3
gkStartStop chnexport "button1", 1

opcode dataRW, k, Ski
Sname, kvalue, iRW      xin
kout init 0
       if (iRW==0) then
              fprintks Sname, "%2.1f\n", kvalue
              kout = kvalue
       else
              kres readk Sname, 8, 0
              kout = kres
       endif
       xout kout
endop


instr 1
gkRW init 3
gkStartStop init 0

if(gkSrc==0) then
abuz  buzz  10000, 0, 1000, 1;
elseif(gkSrc==1) then
abuz randi 10000, 10000;
endif

if(gkStartStop==1 && gkRW==1) then
 kfreq1 dataRW "slider1.txt", gkscrollbar_1, 0
 kfreq2 dataRW "slider2.txt", gkscrollbar_2, 0
 kfreq3 dataRW "slider3.txt", gkscrollbar_3, 0
 kfreq4 dataRW "slider4.txt", gkscrollbar_4, 0
 kfreq5 dataRW "slider5.txt", gkscrollbar_5, 0
elseif(gkStartStop==1 && gkRW==0) then
 kfreq1 dataRW "slider1.txt", gkscrollbar_1, 1
 gkscrollbar_1 = kfreq1
 kfreq2 dataRW "slider2.txt", gkscrollbar_2, 1
 gkscrollbar_2 = kfreq2
 kfreq3 dataRW "slider3.txt", gkscrollbar_3, 1
 gkscrollbar_3 = kfreq3
 kfreq4 dataRW "slider4.txt", gkscrollbar_4, 1
 gkscrollbar_4 = kfreq4
 kfreq5 dataRW "slider5.txt", gkscrollbar_5, 1
 gkscrollbar_5 = kfreq5
endif

if(gkStartStop==0) then
 kfreq1 = gkscrollbar_1
 kfreq2 = gkscrollbar_2
 kfreq3 = gkscrollbar_3
 kfreq4 = gkscrollbar_4
 kfreq5 = gkscrollbar_5
endif

iq1 = 100

; filterbank 1
afl1   reson  abuz,  kfreq1,  (kfreq1/iq1)+5
afl2   reson  afl1,  kfreq2,  (kfreq2/iq1)+5
afl3   reson  afl2,  kfreq3,  (kfreq3/iq1)+5
afl4   reson  afl3,  kfreq4,  (kfreq4/iq1)+5
afl5   reson  afl4,  kfreq5,  (kfreq5/iq1)+5

amix =  afl1+afl2+afl3+afl4+afl5
aout balance amix, abuz
kenv linseg 0, 10, 1
arevL alpass aout, 2, 0.3
arevR alpass aout, 2, 0.15
out (arevL*kenv), (arevR*kenv)
endin



f1 0 4096 10 1
i1 0 3000




On 27 March 2014 16:01, Rory Walsh  wrote:
> You can write the presets to a txt file using foutk, and then read
> them in later. I've done this in the past(very distant past!) to save
> real-time automation data from my MIDI faders. But sure, it's
> definitely possible.
>
> On 27 March 2014 15:54, Dominic Melville  wrote:
>> Hello list,
>>
>> Does anyone know of a specific opcode, UDO or workaround that would allow me
>> to implement typical preset behaviour within a Csound instrument?
>>
>> I've got an instrument running on an RPI that has physical hardware controls
>> including pots, faders etc. I want to be able to save the states of the
>> parameters controlled by the hardware controls as presets, like one would on
>> a typical synth.
>>
>> So for example, I load the basic instrument with it's initial values, play
>> around with the controls tweaking various parameters then once I've got a
>> sound I'm happy with, I want the ability to save and name it for recalling
>> and use later on.
>>
>> Any ideas or thoughts would be greatly appreciated, I've dug through the
>> manual, Floss manual, Csound book and searched online but can't find
>> anything outside of CsoundQT or Cabbage at all. Running either isn't really
>> an option for this project.
>>
>> Thanks
>>
>> Dominic


Send bugs reports to the Sourceforge bug trackers
csound6:
            https://sourceforge.net/p/csound/tickets/
csound5:
            https://sourceforge.net/p/csound/bugs/
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2014-03-27 20:50
FromDominic Melville
Subject[Csnd] Re: Typical Preset Implementation
Excellent, thanks. I'll have a play with it and see what I come up with. 

Cheers Rory, a huge help

Thanks 

Dominic 

On Thursday, March 27, 2014, Rory Walsh <rorywalsh@ear.ie> wrote:
Here's that rather old example I was referring to. It looks like it
will either write the values of the sliders to a text file, or read
the values from the text file and assign, depending on whether
gkStartStop is 1 or not. I'd possibly do it another way if I was doing
it again, but this should still work fine.

<CsoundSynthesizer>
<CsOptions>
-odevaudio -b64 -B4096
</CsOptions>
<CsInstruments>
; Initialize the global variables.
sr = 44100
ksmps = 64
nchnls = 2

gkscrollbar_1 chnexport "scrollbar_1", 3
gkscrollbar_2 chnexport "scrollbar_2", 3
gkscrollbar_3 chnexport "scrollbar_3", 3
gkscrollbar_4 chnexport "scrollbar_4", 3
gkscrollbar_5 chnexport "scrollbar_5", 3
gkStartStop chnexport "button1", 1

opcode dataRW, k, Ski
Sname, kvalue, iRW      xin
kout init 0
       if (iRW==0) then
              fprintks Sname, "%2.1f\n", kvalue
              kout = kvalue
       else
              kres readk Sname, 8, 0
              kout = kres
       endif
       xout kout
endop


instr 1
gkRW init 3
gkStartStop init 0

if(gkSrc==0) then
abuz  buzz  10000, 0, 1000, 1;
elseif(gkSrc==1) then
abuz randi 10000, 10000;
endif

if(gkStartStop==1 && gkRW==1) then
 kfreq1 dataRW "slider1.txt", gkscrollbar_1, 0
 kfreq2 dataRW "slider2.txt", gkscrollbar_2, 0
 kfreq3 dataRW "slider3.txt", gkscrollbar_3, 0
 kfreq4 dataRW "slider4.txt", gkscrollbar_4, 0
 kfreq5 dataRW "slider5.txt", gkscrollbar_5, 0
elseif(gkStartStop==1 && gkRW==0) then
 kfreq1 dataRW "slider1.txt", gkscrollbar_1, 1
 gkscrollbar_1 = kfreq1
 kfreq2 dataRW "slider2.txt", gkscrollbar_2, 1
 gkscrollbar_2 = kfreq2
 kfreq3 dataRW "slider3.txt", gkscrollbar_3, 1
 gkscrollbar_3 = kfreq3
 kfreq4 dataRW "slider4.txt", gkscrollbar_4, 1
 gkscrollbar_4 = kfreq4
 kfreq5 dataRW "slider5.txt", gkscrollbar_5, 1
 gkscrollbar_5 = kfreq5
endif

if(gkStartStop==0) then
 kfreq1 = gkscrollbar_1
 kfreq2 = gkscrollbar_2
 kfreq3 = gkscrollbar_3
 kfreq4 = gkscrollbar_4
 kfreq5 = gkscrollbar_5
endif

iq1 = 100

; filterbank 1
afl1   reson  abuz,  kfreq1,  (kfreq1/iq1)+5
afl2   reson  afl1,  kfreq2,  (kfreq2/iq1)+5
afl3   reson  afl2,  kfreq3,  (kfreq3/iq1)+5
afl4   reson  afl3,  kfreq4,  (kfreq4/iq1)+5
afl5   reson  afl4,  kfreq5,  (kfreq5/iq1)+5

amix =  afl1+afl2+afl3+afl4+afl5
aout balance amix, abuz
kenv linseg 0, 10, 1
arevL alpass aout, 2, 0.3
arevR alpass aout, 2, 0.15
out (arevL*kenv), (arevR*kenv)
endin

</CsInstruments>
<CsScore>
f1 0 4096 10 1
i1 0 3000
</CsScore>
</CsoundSynthesizer>


On 27 March 2014 16:01, Rory Walsh <rorywalsh@ear.ie> wrote:
> You can write the presets to a txt file using foutk, and then read
> them in later. I've done this in the past(very distant past!) to save
> real-time automation data from my MIDI faders. But sure, it's
> definitely possible.
>
> On 27 March 2014 15:54, Dominic Melville <dcamelville@gmail.com> wrote:
>> Hello list,
>>
>> Does anyone know of a specific opcode, UDO or workaround that would allow me
>> to implement typical preset behaviour within a Csound instrument?
>>
>> I've got an instrument running on an RPI that has physical hardware controls
>> including pots, faders etc. I want to be able to save the states of the
>> parameters controlled by the hardware controls as presets, like one would on
>> a typical synth.
>>
>> So for example, I load the basic instrument with it's initial values, play
>> around with the controls tweaking various parameters then once I've got a
>> sound I'm happy with, I want the ability to save and name it for recalling
>> and use later on.
>>
>> Any ideas or thoughts would be greatly appreciated, I've dug through the
>> manual, Floss manual, Csound book and searched online but can't find
>> anything outside of CsoundQT or Cabbage at all. Running either isn't really
>> an option for this project.
>>
>> Thanks
>>
>> Dominic


Send bugs reports to the Sourceforge bug trackers
csound6:
            https://sourceforge.net/p/csound/tickets/
csound5:
            https://sourceforge.net/p/csound/bugs/
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"



Date2014-03-27 20:58
FromJustin Smith
SubjectRe: [Csnd] Re: Typical Preset Implementation
If you want to store everything in one file, you could use vtablek to access the values, vtablewk to update them, and ftload / ftsave to store and retrieve the presets.

As another possibility, using lua or python to store presets in a SQL db would be very useful.


On Thu, Mar 27, 2014 at 1:50 PM, Dominic Melville <dcamelville@gmail.com> wrote:
Excellent, thanks. I'll have a play with it and see what I come up with. 

Cheers Rory, a huge help

Thanks 

Dominic 


On Thursday, March 27, 2014, Rory Walsh <rorywalsh@ear.ie> wrote:
Here's that rather old example I was referring to. It looks like it
will either write the values of the sliders to a text file, or read
the values from the text file and assign, depending on whether
gkStartStop is 1 or not. I'd possibly do it another way if I was doing
it again, but this should still work fine.

<CsoundSynthesizer>
<CsOptions>
-odevaudio -b64 -B4096
</CsOptions>
<CsInstruments>
; Initialize the global variables.
sr = 44100
ksmps = 64
nchnls = 2

gkscrollbar_1 chnexport "scrollbar_1", 3
gkscrollbar_2 chnexport "scrollbar_2", 3
gkscrollbar_3 chnexport "scrollbar_3", 3
gkscrollbar_4 chnexport "scrollbar_4", 3
gkscrollbar_5 chnexport "scrollbar_5", 3
gkStartStop chnexport "button1", 1

opcode dataRW, k, Ski
Sname, kvalue, iRW      xin
kout init 0
       if (iRW==0) then
              fprintks Sname, "%2.1f\n", kvalue
              kout = kvalue
       else
              kres readk Sname, 8, 0
              kout = kres
       endif
       xout kout
endop


instr 1
gkRW init 3
gkStartStop init 0

if(gkSrc==0) then
abuz  buzz  10000, 0, 1000, 1;
elseif(gkSrc==1) then
abuz randi 10000, 10000;
endif

if(gkStartStop==1 && gkRW==1) then
 kfreq1 dataRW "slider1.txt", gkscrollbar_1, 0
 kfreq2 dataRW "slider2.txt", gkscrollbar_2, 0
 kfreq3 dataRW "slider3.txt", gkscrollbar_3, 0
 kfreq4 dataRW "slider4.txt", gkscrollbar_4, 0
 kfreq5 dataRW "slider5.txt", gkscrollbar_5, 0
elseif(gkStartStop==1 && gkRW==0) then
 kfreq1 dataRW "slider1.txt", gkscrollbar_1, 1
 gkscrollbar_1 = kfreq1
 kfreq2 dataRW "slider2.txt", gkscrollbar_2, 1
 gkscrollbar_2 = kfreq2
 kfreq3 dataRW "slider3.txt", gkscrollbar_3, 1
 gkscrollbar_3 = kfreq3
 kfreq4 dataRW "slider4.txt", gkscrollbar_4, 1
 gkscrollbar_4 = kfreq4
 kfreq5 dataRW "slider5.txt", gkscrollbar_5, 1
 gkscrollbar_5 = kfreq5
endif

if(gkStartStop==0) then
 kfreq1 = gkscrollbar_1
 kfreq2 = gkscrollbar_2
 kfreq3 = gkscrollbar_3
 kfreq4 = gkscrollbar_4
 kfreq5 = gkscrollbar_5
endif

iq1 = 100

; filterbank 1
afl1   reson  abuz,  kfreq1,  (kfreq1/iq1)+5
afl2   reson  afl1,  kfreq2,  (kfreq2/iq1)+5
afl3   reson  afl2,  kfreq3,  (kfreq3/iq1)+5
afl4   reson  afl3,  kfreq4,  (kfreq4/iq1)+5
afl5   reson  afl4,  kfreq5,  (kfreq5/iq1)+5

amix =  afl1+afl2+afl3+afl4+afl5
aout balance amix, abuz
kenv linseg 0, 10, 1
arevL alpass aout, 2, 0.3
arevR alpass aout, 2, 0.15
out (arevL*kenv), (arevR*kenv)
endin

</CsInstruments>
<CsScore>
f1 0 4096 10 1
i1 0 3000
</CsScore>
</CsoundSynthesizer>


On 27 March 2014 16:01, Rory Walsh <rorywalsh@ear.ie> wrote:
> You can write the presets to a txt file using foutk, and then read
> them in later. I've done this in the past(very distant past!) to save
> real-time automation data from my MIDI faders. But sure, it's
> definitely possible.
>
> On 27 March 2014 15:54, Dominic Melville <dcamelville@gmail.com> wrote:
>> Hello list,
>>
>> Does anyone know of a specific opcode, UDO or workaround that would allow me
>> to implement typical preset behaviour within a Csound instrument?
>>
>> I've got an instrument running on an RPI that has physical hardware controls
>> including pots, faders etc. I want to be able to save the states of the
>> parameters controlled by the hardware controls as presets, like one would on
>> a typical synth.
>>
>> So for example, I load the basic instrument with it's initial values, play
>> around with the controls tweaking various parameters then once I've got a
>> sound I'm happy with, I want the ability to save and name it for recalling
>> and use later on.
>>
>> Any ideas or thoughts would be greatly appreciated, I've dug through the
>> manual, Floss manual, Csound book and searched online but can't find
>> anything outside of CsoundQT or Cabbage at all. Running either isn't really
>> an option for this project.
>>
>> Thanks
>>
>> Dominic


Send bugs reports to the Sourceforge bug trackers
csound6:
            https://sourceforge.net/p/csound/tickets/
csound5:
            https://sourceforge.net/p/csound/bugs/
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"




Date2014-03-27 22:31
FromDominic Melville
Subject[Csnd] Re: Typical Preset Implementation
That's a good idea. I never thought of Lua or Python, so obvious I should've thought of that. 

Thanks 

Dominic 

On Thursday, March 27, 2014, Justin Smith <noisesmith@gmail.com> wrote:
If you want to store everything in one file, you could use vtablek to access the values, vtablewk to update them, and ftload / ftsave to store and retrieve the presets.

As another possibility, using lua or python to store presets in a SQL db would be very useful.


On Thu, Mar 27, 2014 at 1:50 PM, Dominic Melville <dcamelville@gmail.com> wrote:
Excellent, thanks. I'll have a play with it and see what I come up with. 

Cheers Rory, a huge help

Thanks 

Dominic 


On Thursday, March 27, 2014, Rory Walsh <rorywalsh@ear.ie> wrote:
Here's that rather old example I was referring to. It looks like it
will either write the values of the sliders to a text file, or read
the values from the text file and assign, depending on whether
gkStartStop is 1 or not. I'd possibly do it another way if I was doing
it again, but this should still work fine.

<CsoundSynthesizer>
<CsOptions>
-odevaudio -b64 -B4096
</CsOptions>
<CsInstruments>
; Initialize the global variables.
sr = 44100
ksmps = 64
nchnls = 2

gkscrollbar_1 chnexport "scrollbar_1", 3
gkscrollbar_2 chnexport "scrollbar_2", 3
gkscrollbar_3 chnexport "scrollbar_3", 3
gkscrollbar_4 chnexport "scrollbar_4", 3
gkscrollbar_5 chnexport "scrollbar_5", 3
gkStartStop chnexport "button1", 1

opcode dataRW, k, Ski
Sname, kvalue, iRW      xin
kout init 0
       if (iRW==0) then
              fprintks Sname, "%2.1f\n", kvalue
              kout = kvalue
       else
              kres readk Sname, 8, 0
              kout = kres
       endif
       xout kout
endop


instr 1
gkRW init 3
gkStartStop init 0

if(gkSrc==0) then
abuz  buzz  10000, 0, 1000, 1;
elseif(gkSrc==1) then
abuz randi 10000, 10000;
endif

if(gkStartStop==1 && gkRW==1) then
 kfreq1 dataRW "slider1.txt", gkscrollbar_1, 0
 kfreq2 dataRW "slider2.txt", gkscrollbar_2, 0
 kfreq3 dataRW "slider3.txt", gkscrollbar_3, 0
 kfreq4 dataRW "slider4.txt", gkscrollbar_4, 0
 kfreq5 dataRW "slider5.txt", gkscrollbar_5, 0
elseif(gkStartStop==1 && gkRW==0) then
 kfreq1 dataRW "slider1.txt", gkscrollbar_1, 1
 gkscrollbar_1 = kfreq1
 kfreq2 dataRW "slider2.txt", gkscrollbar_2, 1
 gkscrollbar_2 = kfreq2
 kfreq3 dataRW "slider3.txt", gkscrollbar_3, 1
 gkscrollbar_3 = kfreq3
 kfreq4 dataRW "slider4.txt", gkscrollbar_4, 1
 gkscrollbar_4 = kfreq4
 kfreq5 dataRW "slider5.txt", gkscrollbar_5, 1
 gkscrollbar_5 = kfreq5
endif

if(gkStartStop==0) then
 kfreq1 = gkscrollbar_1
 kfreq2 = gkscrollbar_2
 kfreq3 = gkscrollbar_3
 kfreq4 = gkscrollbar_4
 kfreq5 = gkscrollbar_5
endif

iq1 = 100

; filterbank 1
afl1   reson  abuz,  kfreq1,  (kfreq1/iq1)+5
afl2   reson  afl1,  kfreq2,  (kfreq2/iq1)+5
afl3   reson  afl2,  kfreq3,  (kfreq3/iq1)+5
afl4   reson  afl3,  kfreq4,  (kfreq4/iq1)+5
afl5   reson  afl4,  kfreq5,  (kfreq5/iq1)+5

amix =  afl1+afl2+afl3+afl4+afl5
aout balance amix, abuz
kenv linseg 0, 10, 1
arevL alpass aout, 2, 0.3
arevR alpass aout, 2, 0.15
out (arevL*kenv), (arevR*kenv)
endin

</CsInstruments>
<CsScore>
f1 0 4096 10 1
i1 0 3000
</CsScore>
</CsoundSynthesizer>


On 27 March 2014 16:01, Rory Walsh <rorywalsh@ear.ie> wrote:
> You can write the presets to a txt file using foutk, and then read
> them in later. I've done this in the past(very distant past!) to save
> real-time automation data from my MIDI faders. But sure, it's
> definitely possible.
>
> On 27 March 2014 15:54, Dominic Melville <dcamelville@gmail.com> wrote:
>> Hello list,
>>
>> Does anyone know of a specific opcode, UDO or workaround that would allow me
>> to implement typical preset behaviour within a Csound instrument?
>>
>> I've got an instrument running on an RPI that has physical hardware controls
>> including pots, faders etc. I want to be able to save the states of the
>> parameters controlled by the hardware controls as presets, like one would on
>> a typical synth.
>>
>> So for example, I load the basic instrument with it's initial values, play
>