back to list

Csound improv with Arduino

🔗Dave Seidel <dave@...>

8/6/2011 2:45:41 PM

Nothing profound, just messing around with my latest project:
controlling Csound in real time using an Arduino box that my brother
built for me. I'm using Pure Data as the glue: the pduino package talks
to the Arduino via the Firmata firmware, and I use csoundapi~ control
Csound. The Csound instrument is a variant of one I've used before that
generates combination (i.e., difference and summation) tones based on
intervals defined as ratios. Since there are separate controls for the
numerators and denominators, and each one is defined as producing a
range of integers from 1 to 256, this allows me to play with both
overtone and undertone series. There's more explanation on the
SoundCloud page.

I've attached the Csound and Pd code if you're curious, though the Pd
patch will not run without a few other files (write me if you want to
see them). In the Pd path, the "r" ("receive") objects are where the
signals come in from the Arduino.

http://soundcloud.com/mysterybear/difference-engine-study-1

- Dave

http://mysterybear.net
http://soundcloud.com/mysterybear
http://mysterybear.bandcamp.com

----------

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
nchnls = 1
0dbfs = 1
ksmps = 4

giTblSz init 1048576

; sine wave
giFn1 ftgen 1, 0, giTblSz, 10, 1

; "Fibonacci" wave (Mt. Meru A)
giFn2 ftgen 2, 0, giTblSz, 9, 1,1,0, 2,.5,0, 3,.3333,0, 5,.2,0, 8,.125,0, 13,.0769,0, 21,.0476,0, ;34,.0294,0, ;55,.0182,0, ;89,.0112,0 ;144,.0069,0

; harmonics in the Fibonacci series (smaller set)
giFn3 ftgen 3, 0, giTblSz, 9, 1,1,0, 2,.5,0, 3,.3333,0;, 5,.2,0, 8,.125,0, 13,.0769,0, 21,.0476,0, ;34,.0294,0, ;55,.0182,0, ;89,.0112,0 ;144,.0069,0

; prime wave
giFn34 ftgen 4, 0, giTblSz, 9, 1,1,0, 2,.5,0, 3,.3333,0, 5,.2,0, 7,.143,0, 11,.0909,0, 13,.077,0, 17,.0588,0, 19,.0526,0, 23,.0435,0, ;27,.037,0

;---------------------------------------------------------------------------------------
; combination tone chord organ: given a note and a ratio, produces the chord formed
; by that interval plus the set of notes equivalent to the combination tones produced
; by that interval
;---------------------------------------------------------------------------------------

instr 1

idur = p3 ; duration
iamp = ampdb(p4)/8 ; amplitude
ipan = p5 ; pan
ifn = p6 ; function table
ichan = p7 ; invalue suffix

S1 sprintf "pitch%d", ichan
S2 sprintf "numerator%d", ichan
S3 sprintf "denominator%d", ichan

kpch1 invalue S1
kmmm invalue S2
knnn invalue S3

kpch2 = kpch1*(kmmm/knnn) ; secondary pitch (primary * ratio)
kdiff = kpch2-kpch1 ; difference tone
kdiff2 = (2*kpch2)-kpch1 ; 2nd order difference tone
kdiff3 = (3*kpch2)-(2*kpch1) ; 3rd order difference tone
kper = kpch1/knnn ; periodicity pitch, shifted up one 8ve
ksum = kpch1+kpch2 ; summation tone
ksum2 = (2*kpch1)+kpch2 ; 2nd order summation tone

kenv linen iamp, 2, idur, 3 ; envelope

asig1 oscili kenv, kpch1, ifn
asig2 oscili kenv, kpch2, ifn
adiff oscili kenv, kdiff, ifn
adiff2 oscili kenv, kdiff2, ifn
adiff3 oscili kenv, kdiff3, ifn
aper oscili kenv, kper, ifn
asum oscili kenv, ksum, ifn
asum2 oscili kenv, ksum2, ifn

aout sum asig1,asig2,adiff,adiff2,adiff3,aper,asum,asum2
out aout

endin

</CsInstruments>
<CsScore>

; top row (channel 1)
i1 0 3600 -5 0 2 1
i1 0 3600 -5 0 4 1

; bottom row (channel 2)
i1 0 3600 -5 0 2 2
i1 0 3600 -5 0 4 2

e

</CsScore>
</CsoundSynthesizer>

----------

#N canvas 254 21 1000 650 10;
#X floatatom 661 406 5 0 0 0 - - -;
#X floatatom 514 399 5 0 0 0 - - -;
#X obj 161 435 dac~;
#X obj 143 374 csoundapi~ difference_engine.csd;
#X obj 612 11 box-10;
#X obj 13 552 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 13 583 dsp;
#X obj 114 234 loadbang;
#X obj 12 516 r d13;
#X msg 478 436 control pitch1 \$1;
#X msg 624 437 control numerator1 \$1;
#X floatatom 825 405 5 0 0 0 - - -;
#X obj 518 308 r a0;
#X obj 663 294 r a1;
#X obj 829 297 r a2;
#X msg 793 438 control denominator1 \$1;
#X obj 519 367 + 30;
#X obj 663 352 int;
#X obj 823 350 int;
#X obj 518 337 * 1200;
#X obj 661 323 * 256;
#X obj 827 324 * 256;
#X floatatom 509 572 5 0 0 0 - - -;
#X obj 511 521 + 30;
#X obj 509 495 * 1200;
#X floatatom 675 572 5 0 0 0 - - -;
#X obj 670 516 int;
#X obj 670 491 * 256;
#X floatatom 823 573 5 0 0 0 - - -;
#X obj 825 523 int;
#X obj 825 499 * 256;
#X msg 112 272 set pitch1 numerator1 denominator1 pitch2 numerator2
denominator2;
#X msg 480 601 control pitch2 \$1;
#X msg 629 600 control numerator2 \$1;
#X msg 785 601 control denominator2 \$1;
#X obj 510 466 r a3;
#X obj 670 463 r a4;
#X obj 825 469 r a5;
#X obj 63 551 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X msg 66 585 run \$1;
#X msg 133 585 reset;
#X obj 64 514 r d12;
#X text 7 608 Sound;
#X text 74 609 Run;
#X text 123 609 Recompile;
#X obj 827 376 + 1;
#X obj 662 378 + 1;
#X obj 671 544 + 1;
#X obj 827 547 + 1;
#X connect 0 0 10 0;
#X connect 1 0 9 0;
#X connect 3 0 2 0;
#X connect 3 0 2 1;
#X connect 5 0 6 0;
#X connect 7 0 31 0;
#X connect 8 0 5 0;
#X connect 9 0 3 0;
#X connect 10 0 3 0;
#X connect 11 0 15 0;
#X connect 12 0 19 0;
#X connect 13 0 20 0;
#X connect 14 0 21 0;
#X connect 15 0 3 0;
#X connect 16 0 1 0;
#X connect 17 0 46 0;
#X connect 18 0 45 0;
#X connect 19 0 16 0;
#X connect 20 0 17 0;
#X connect 21 0 18 0;
#X connect 22 0 32 0;
#X connect 23 0 22 0;
#X connect 24 0 23 0;
#X connect 25 0 33 0;
#X connect 26 0 47 0;
#X connect 27 0 26 0;
#X connect 28 0 34 0;
#X connect 29 0 48 0;
#X connect 30 0 29 0;
#X connect 31 0 3 0;
#X connect 32 0 3 0;
#X connect 33 0 3 0;
#X connect 34 0 3 0;
#X connect 35 0 24 0;
#X connect 36 0 27 0;
#X connect 37 0 30 0;
#X connect 38 0 39 0;
#X connect 39 0 3 0;
#X connect 40 0 3 0;
#X connect 41 0 38 0;
#X connect 45 0 11 0;
#X connect 46 0 0 0;
#X connect 47 0 25 0;
#X connect 48 0 28 0;

[Non-text portions of this message have been removed]