Skip to content

Commit

Permalink
updating channel state opcodes for use at k-time
Browse files Browse the repository at this point in the history
  • Loading branch information
rorywalsh committed Oct 24, 2019
1 parent 2fa4cbf commit a9bb6bd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 11 deletions.
Binary file modified docs/channelStateRecall.md
Binary file not shown.
57 changes: 46 additions & 11 deletions docs/channelStateSave.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This opcode will save the value of each channel declared in a Csound orchestra t
### Syntax
```csound
iRes channelStateSave SFilename
kRes channelStateSave SFilename
```

### Initialization
Expand All @@ -20,32 +21,66 @@ iRes channelStateSave SFilename

### Performance

> This opcode works at i-time only.
* **kRes** -- 1 for success, 0 for fail
* **SFilename** -- filename

### Example
This example shows channelStateSave being used to save the current states of a all Cabbage widgets to disk. The states can be recalled using the `channelStateRecall` opcode.

```csound
<Cabbage>
form caption("Presets") size(370, 280), colour(58, 110, 182), pluginid("fsad")
keyboard bounds(10, 90, 345, 95)
rslider bounds(12, 8, 85, 79), channel("att"), range(0, 1, 0.01), text("Att.")
rslider bounds(98, 8, 85, 79), channel("dec"), range(0, 1, 0.4), text("Dec.")
rslider bounds(184, 8, 85, 79), channel("sus"), range(0, 1, 0.7), text("Sus.")
rslider bounds(270, 8, 85, 79), channel("rel"), range(0, 1, 0.8), text("Rel.")
combobox bounds(92, 192, 226, 25), populate("*.txt", "."), channel("recallCombo"), channeltype("string"), identchannel("recallComboIdent")
button bounds(10, 192, 80, 40), channel("triggerSave"), text("Save state")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac --opcode-lib=../build/libstrRemove.dylib
;-iadc ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o diskin.wav -W ;;; for file output any platform
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5 --opcode-lib=C:\Users\rory\sourcecode\csoundPlugins\build\Debug\channelStateOpcodes.dll
</CsOptions>
<CsInstruments>
0dbfs=1
; Initialize the global variables.
;sr is set by the host
ksmps = 32
nchnls = 2
0dbfs = 1
gkFileNumber init 10
instr 1
SString = "Hello there, my name is Rory"
SOutput strRemove SString, "Hello there, "
prints SOutput
kEnv madsr chnget:i("att"), chnget:i("dec"), chnget:i("sus"), chnget:i("rel")
aOut vco2 kEnv*p5, p4
outs aOut, aOut
endin
instr 10
SFilename chnget "recallCombo"
if changed2:k(SFilename) == 1 then
SIgnoreChannels[] init 2
SIgnoreChannels[0] = "triggerSave"
SIgnoreChannels[1] = "recallCombo"
kOk = channelStateRecall:k(SFilename, SIgnoreChannels)
endif
if changed:k(chnget:k("triggerSave")) == 1 then
SPath = chnget:S("CSD_PATH")
SFilename = sprintfk:S("PresetTest%d.txt", gkFileNumber)
printks "%s", 0, SFilename
kOk = channelStateSave:k(SFilename)
gkFileNumber+=1
chnset "refreshfiles()", "recallComboIdent"
endif
endin
</CsInstruments>
<CsScore>
i1 0 1
;causes Csound to run for about 7000 years...
i10 0 z
</CsScore>
</CsoundSynthesizer>
```
Expand Down

0 comments on commit a9bb6bd

Please sign in to comment.