Cabbage Logo
Back to Cabbage Site

How to make two instruments sound at the same time?

<Cabbage>
form caption("Untitled") size(400, 300), colour(58, 110, 182), pluginid("def1")
keyboard bounds(8, 158, 381, 95)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

;instrument will be triggered by keyboard widget

massign 0,0
massign 0,1
massign 0,2


instr 1
kEnv madsr .9, .2, .6, .4
aOut poscil p5, p4, 2
outs aOut*kEnv, aOut*kEnv
endin

instr 2
kEnv madsr .1, .2, .6, .4
aOut poscil p5, p4, 1
outs aOut*kEnv, aOut*kEnv
endin




</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f1 0 16384 10 1                                          ; Sine
f2 0 16384 10 1 0.5 0.3 0.25 0.2 0.167 0.14 0.125 .111   ; Sawtooth
f3 0 16384 10 1 0   0.3 0    0.2 0     0.14 0     .111   ; Square
f4 0 16384 10 1 1   1   1    0.7 0.5   0.3  0.1          ; Pulse

i1 0 z
i2 0 z

</CsScore>
</CsoundSynthesizer>

I’m not sure you can use massign to send MIDI information to two instruments on a single channel. But you can just make one instrument that does what you want. Btw, I edited your post to format your code. The '</> button will format selected code. It makes it much easier to read.

Hello, I want to make two oscillators, and then both oscillators are equipped with an FM pronunciation operator for modulation. My problem is that when the contents of the pronunciation operators are the same, I want to copy many pronunciation operators directly. There are many situations at this time, for example, the names of the knobs cannot be the same, otherwise they will be occupied. Only change the name of each output or input port so that they do not occupy each other. But this will be very cumbersome. Therefore, we want to use the two oscillators as two musical instruments, and finally merge the sounds, so that the trouble of modifying the parameter names for two identical pronunciation operators can be solved. Do you have a better suggestion. I want to make one with two oscillators, each with an FM pronunciation operator. Pronunciation operator is equipped with octave modulation, semitone, cent, ADSR, and other modulation functions

Sorry, I don’t quite follow what you trying to do. Have you considered creating a UDO and putting as many of them as you like into a to single instrument?

How to merge TR-808.csd and Oscilloscope.csd of the software together and use the page to switch

如何将软件的TR-808.csd和Oscilloscope.csd合并在一起并使用页面进行切换

That will be quite a lot of work I fear, especially if you did not write either source yourself. You would first need to create place all the GUI controls from one instrument into a plant, and then the same with the other. Then add a button to switch between the two. After that you will need to look at the Csound end of things. It’s not going to be trivial. You may have more success starting from scratch and writing your own code.