<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<?xml-stylesheet href="./_c74_ref.xsl" type="text/xsl"?>

<!--This is an automatically generated file. DO NOT EDIT THIS FILE DIRECTLY. Rather, use the _ref.xml files found in the 'edits' folder.-->
<c74object name="ftom" module="max" category="Math">
	<digest>
		Convert frequency to a MIDI note number
	</digest>
	<description>
		<o>ftom</o> converts frequency to MIDI note numbers
	</description>
	<!--METADATA-->
	<metadatalist>
		<metadata name="author">
			Cycling '74
		</metadata>
		<metadata name="tag">
			Max
		</metadata>
		<metadata name="tag">
			math
		</metadata>
		<metadata name="tag">
			MIDI
		</metadata>
		<metadata name="reference">
			TEXT_HERE
		</metadata>
		<metadata name="license">
			TEXT_HERE
		</metadata>
	</metadatalist>
	<!--INLETS-->
	<inletlist>
		<inlet id="0" type="INLET_TYPE">
			<digest>
				Frequency In
			</digest>
			<description>
				TEXT_HERE
			</description>
		</inlet>
		<inlet id="1" type="INLET_TYPE">
			<digest>
			</digest>
			<description>
				TEXT_HERE
			</description>
		</inlet>
	</inletlist>
	<!--OUTLETS-->
	<outletlist>
		<outlet id="0" type="OUTLET_TYPE">
			<digest>
				MIDI Note Number Out
			</digest>
			<description>
				TEXT_HERE
			</description>
		</outlet>
	</outletlist>
	<!--ARGUMENTS-->
	<objarglist>
		<objarg name="format" optional="1" type="float">
			<digest>
				Float output
			</digest>
			<description>
				If a float value is present, the <o>ftom</o> object outputs floating-point values with fractional parts. By default, it outputs whole number values.
			</description>
		</objarg>
	</objarglist>
	<!--MESSAGES-->
	<methodlist>
		<method name="int">
			<arglist>
				<arg name="frequency" optional="0" type="int" />
			</arglist>
			<digest>
				Convert frequency to MIDI note number
			</digest>
			<description>
				Outputs the MIDI note number (from 0 to 127) corresponding to the frequency
			</description>
		</method>
		<method name="float">
			<arglist>
				<arg name="frequency" optional="0" type="float" />
			</arglist>
			<digest>
				Convert frequency to MIDI note number
			</digest>
			<description>
				Outputs the MIDI note number (from 0 to 127) corresponding to the frequency
			</description>
		</method>
		<method name="list">
			<arglist>
				<arg name="list of frequencies" optional="0" type="list" />
			</arglist>
			<digest>
				Convert frequencies to MIDI note numbers
			</digest>
			<description>
				Outputs a list of MIDI note numbers (from 0 to 127) corresponding to the frequencies in the input list
			</description>
		</method>
	</methodlist>
	<!--ATTRIBUTES-->
	<attributelist>
		<attribute name="base" get="1" set="1" type="float" size="1">
			<digest>
				Base frequency
			</digest>
			<description>
				Sets the &quot;base frequency&quot; used when converting frequency values (e.g., A = 440.). The default is 440.
			</description>
			<attributelist>
				<attribute name="label" get="1" set="1" type="symbol" size="1" value="Base Frequency" />
			</attributelist>
		</attribute>
		<attribute name="map" get="1" set="1" type="atom" size="1">
			<digest>
				Keyboard Map
			</digest>
			<description>
				A set of values for a keyboard map in Scala format:
				<ul>
					<li>
						Size of map; the pattern repeats every so many keys (example: 12)
					</li>
					<li>
						First MIDI note number to retune (example: 0)
					</li>
					<li>
						Last MIDI note number to retune (example: 127)
					</li>
					<li>
						Middle note where the first entry of the mapping is mapped to (example: 60)
					</li>
					<li>
						Reference note for which frequency is given (example: 69)
					</li>
					<li>
						Frequency for reference note, as a float (example: 440.0)
					</li>
					<li>
						Frequency for reference note, as a float (example: 440.0)
					</li>
					<li>
						Scale degree to consider as formal octave, determines difference in pitch between adjacent mapping patterns (example: 12)
					</li>
					<li>
						Mapping (example: 0 1 2 3 4 5 6 7 8 9 10 11)
					</li>
				</ul>
				Note: to indicate an unmapped key, you can use either an &quot;x&quot; or &quot;-1&quot;. At the end of the list, unmapped keys may be left out. For more information about keyboard mappings, visit
				<a href="https://www.huygens-fokker.org/scala/help.htm#mappings">
					the Scala documentation.
				</a>
			</description>
			<attributelist>
				<attribute name="label" get="1" set="1" type="symbol" size="1" value="Keyboard Map" />
			</attributelist>
		</attribute>
		<attribute name="mapname" get="1" set="1" type="symbol" size="1">
			<digest>
				Keyboard Map File
			</digest>
			<description>
				The name of a valid keyboard map file in Scala format that has been saved in Max's search path will cause <o>ftom</o> to use that mapping. The file extension (.kbm) can be omitted. For more information about keyboard mappings, visit
				<a href="https://www.huygens-fokker.org/scala/help.htm#mappings">
					the Scala documentation.
				</a>
			</description>
			<attributelist>
				<attribute name="label" get="1" set="1" type="symbol" size="1" value="Keyboard Map File" />
				<attribute name="style" get="1" set="1" type="symbol" size="1" value="filename" />
			</attributelist>
		</attribute>
		<attribute name="mid" get="1" set="1" type="int" size="1">
			<digest>
				Middle Note Number
			</digest>
			<description>
				The note number where a Scala scale begins (default 60).
			</description>
			<attributelist>
				<attribute name="label" get="1" set="1" type="symbol" size="1" value="Middle Note Number" />
			</attributelist>
		</attribute>
		<attribute name="ref" get="1" set="1" type="int" size="1">
			<digest>
				Reference Note Number
			</digest>
			<description>
				The MIDI note number assigned to the base frequency (default 69).
			</description>
			<attributelist>
				<attribute name="label" get="1" set="1" type="symbol" size="1" value="Reference Note Number" />
			</attributelist>
		</attribute>
		<attribute name="round" get="1" set="1" type="int" size="1">
			<digest>
				Round Output
			</digest>
			<description>
				When <at>round</at> is non-zero, <o>ftom</o> outputs the closest whole MIDI note number value for the frequency it receives. Otherwise if in float mode, <o>ftom</o> outputs a number with a fractional part corresponding to the distance between the two closest MIDI note numbers. If <o>ftom</o> is in int output mode, it outputs the MIDI note number at or below the input frequency value. Example: in int mode with other attributes at their default values, 439 would output 69 when <at>round</at> is enabled and 68 when <at>round</at> disabled. 439 is closest to 440 Hz (MIDI note number 69).
			</description>
			<attributelist>
				<attribute name="label" get="1" set="1" type="symbol" size="1" value="Round Output" />
				<attribute name="style" get="1" set="1" type="symbol" size="1" value="onoff" />
			</attributelist>
		</attribute>
		<attribute name="scale" get="1" set="1" type="atom" size="1">
			<digest>
				Scale Data
			</digest>
			<description>
				A set of values, given as a list, for a scale described using the Scala format. The first value is the count of notes, followed either by floats defining a value in cents (example: 579.47057) or a ratio of two ints (example: 5/4). For more information, see
				<a href="https://www.huygens-fokker.org/scala/scl_format.html">
					the Scala documentation.
				</a>
			</description>
			<attributelist>
				<attribute name="label" get="1" set="1" type="symbol" size="1" value="Scale Data" />
				<attribute name="style" get="1" set="1" type="symbol" size="1" value="text_large" />
			</attributelist>
		</attribute>
		<attribute name="scalename" get="1" set="1" type="symbol" size="1">
			<digest>
				Scale Name
			</digest>
			<description>
				A valid scale name from the
				<a href="https://www.huygens-fokker.org/docs/scalesdir.txt">
					Scala archive
				</a>
				, will cause <o>ftom</o> to use the tuning described in that scale for its frequency to MIDI conversion. For this purposes of this attribute, the file extension (.scl) can be omitted.
			</description>
			<attributelist>
				<attribute name="label" get="1" set="1" type="symbol" size="1" value="Scale Name" />
			</attributelist>
		</attribute>
	</attributelist>
	<!--EXAMPLE-->
	<examplelist>
		<example img="ftom.png" caption="Find the MIDI key number to play the same pitch as an MSP oscillator" />
	</examplelist>
	<!--SEEALSO-->
	<seealsolist>
		<seealso name="expr" />
		<seealso name="ftom~" />
		<seealso name="mtof" />
	</seealsolist>
	<misc name="Output">
		<entry name="int">
			<description>
				The MIDI note number that corresponds to the input frequency. When an input frequency falls between two equal tempered pitches, the value is rounded to the nearest int when <o>ftom</o> is used in its default int mode. When <o>ftom</o> is used in the optional float mode, the fractional part of the float is included, which could be used to calculate an additional pitch offset for applying MIDI pitch bend.
			</description>
		</entry>
		<entry name="float">
			<description>
				The MIDI note number that corresponds to the input frequency. When an input frequency falls between two equal tempered pitches, the value is rounded to the nearest int when <o>ftom</o> is used in its default int mode. When <o>ftom</o> is used in the optional float mode, the fractional part of the float is included, which could be used to calculate an additional pitch offset for applying MIDI pitch bend.
			</description>
		</entry>
	</misc>
</c74object>
