Actually I came up with the same solution like @lis0r.
My problem was a bit different, I wanted to "retune" the notes of a keyboard. For this purpose I modified an existing purpose and did some data type conversions. I only used one octave of the midi keyboard and defined a list of frequencies that were then converted to pitch.
I'll just post the XML Code here. Perhaps this will help some of you guys. If you have any questions just let me know. Actually I think it's quite doable to write an object that accepts frequencies and outputs the corresponding pitch.
<axoObjectPatcherObject id="pitch_hack" uuid="6b958b82fafa8d61216203d28f9f0e4cd27fa2a6" sha="1bffe2143076d9d67735f75abda79ef4c82db4ac">
<upgradeSha>61413e41a22dba4d3f6a4be145c06146934f7120</upgradeSha>
<author>Andrea Heilrath</author>
<license>BSD</license>
<helpPatch>math.axh</helpPatch>
<inlets>
<frac32.bipolar name="note" description="note"/>
</inlets>
<outlets>
<frac32.bipolar name="pitch" description="pitch"/>
<frac32.positive name="amp" description="amp"/>
</outlets>
<displays/>
<params/>
<attribs/>
<file-depends/>
<includes/>
<depends/>
<modules/>
<code.declaration><![CDATA[float frequencies[12] = {220, 220, 220, 220, 440, 440, 440, 440, 880, 880, 880, 880};
float amplitudes[12] = {0.2, 0.5, 0.8, 1.0, 0.2, 0.5, 0.8, 1.0, 0.2, 0.5, 0.8, 1.0};
int semi_tone = 2097152;
int ref_e4 = 134217728;
int key = 0;
int32_t freq2pitch(float freq){
return int32_t(2097152.0 * 12.0 * log2f(freq/329.63)); //reference pitch e4, 134217728
}
int32_t famp2intamp(float amp){
return int32_t(134217728*amp);
}
int determine_key (int input_pitch){
return ((input_pitch + 134217728) % (12 * 2097152)) / 2097152;
}]]></code.declaration>
<code.init><![CDATA[]]></code.init>
<code.dispose><![CDATA[]]></code.dispose>
<code.krate><![CDATA[key = determine_key(inlet_note);
outlet_pitch = freq2pitch(frequencies[key]);
outlet_amp = famp2intamp(amplitudes[key]);]]></code.krate>
<code.srate><![CDATA[]]></code.srate>
<code.midihandler><![CDATA[]]></code.midihandler>
</axoObjectPatcherObject>