[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] Re: a MIDIFunc that doesn't work



Your syntax here is incorrect:

MIDIFunc.noteOn({|vel, num| if(num == 71){SinOsc.ar(440, 0, 0.5)}.play;});

Specifically, you close the parentheses your conditional "if" too soon.

Here, the syntax error is corrected:

MIDIFunc.noteOn({|vel, num| if(num == 71, {{SinOsc.ar(440, 0,
0.5)}.play})});

But IMO it is far clearer on multiple lines:

(
MIDIFunc.noteOn({
	|vel, num|
	if(
		num == 71,
		{
			{SinOsc.ar(440, 0, 0.5)}.play;
		}
	);
});
)

The following code will play a sine wave at a frequency corresponding to the
played MIDI note:

(
MIDIFunc.noteOn({
	|vel, num|
	{SinOsc.ar(num.midicps, 0, 0.2)}.play;
});
)

Still fairly crude though, because note off information is ignored, there
are no envelopes, etc.

Eli



--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/a-MIDIFunc-that-doesn-t-work-tp7629724p7629725.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/