Pkey, special case


#1

Hi guys,
is there a way to obtain the value of midinote via Pkey inside a Pbind even if midinotes are not expressed explicitly?

In other terms, I need the midinote value in order to do some calculation to find out a specific index inside a buffer array and also to get the rate at which this buffer would be played back but I don’t want to provide midinote explicitly. Instead I want to work with scale, degrees, etc…

Here’s an example code

Pbind(
	\instrument, \myInstrument,
	\scale, Scale.minor,
	\root, 0,
	\octave, 5, 
	\degree, Pseq([0, 1, 2, 3], inf),
	\myParameter, Pkey(\midinote) // I will make some custom calculation on this
)

The code above doesn’t work while it works if I specify the midinotes inside the pattern

Pbind(
	\instrument, \myInstrument,
	\midinote, Pseq([60, 67, 45], inf),
	\myParameter, Pkey(\midinote) // I will make some custom calculation on this
)

Is there a way to make the first snippet work?
thank you so much.


#2

~midinote is a Function in the pitchEvent, you can call it like this:

Pbind(
	\instrument, \default,
	\scale, Scale.minor,
	\root, 0,
	\octave, 5, 
	\degree, Pseq([0, 1, 2, 3], inf),
	// pass the current Event to Pfunc, do your calculation in there
	\myParameter, Pfunc { |e| e.use { |self| self[\midinote].value } }
).trace.play

#3

A shorter variant:

\myParameter, Pfunc { |e| e.use { ~midinote.() } }

#4

Thanks @dkmayer for your reply.
And also I like to thank you for explaining me some of the theory behind: I will go deeper into this.
Thank you so much