The simplest way would be to create an instrument that is always playing and then simply test if the button is on or off. For example, if
instr 1 is always playing (
i1 0 z in the score), it will check the value of the button with channel
button1 on each k-cycle. If it is on it will enter the if block of code.
if chnget:k("button1") == 1 then
//make some sounds here
It's very hard to answer that as I have no idea what type of sound you wish to create. A simple sine wave can play continuous data for as long as you like. Any number of synthesis techniques can be used in this situation.
Chords can be created by layering instances of instruments on top of each other. For example, this example will play a chord each time one presses a button.
kButtonValue chnget "button1"
if changed(kButtonValue) == 1 then
event "i", 2, 0, 2, 60
event "i", 2, 0, 2, 64
event "i", 2, 0, 2, 67
aEnv madsr .1, .4, .4, .1
a1 oscili .25, cpsmidinn(p4)
outs a1*aEnv, a1*aEnv
Note that instrumnt 1 is started from the score, but instrument 2 is triggered to play from instrument 1.
There are a number of file reading opcodes in Csound that you can explore. It depends to a large extent on how the data is presented in the file you are trying to read from. Take a look at some of these opcodes.
Let us know how you get on.