User:Contribution/Chanopif Project

From Xenharmonic Wiki
Jump to navigation Jump to search

Chanopif (short for Channel-Note-Pitch-Fractional pitch) is a proposed file format and specification designed to enable precise microtonal tuning for electronic and software-based musical instruments under the MIDI 2.0 standard. The format uses the .cnpf file extension and leverages the 7.25 pitch attribute (Registered Per-Note Controller #3) defined in MIDI 2.0 to achieve extremely fine pitch resolution—specifically 402,653,184 subdivisions per octave (402,653,184-EDO).

Etymology

The name Chanopif is derived from its four core elements:

  1. Cha-: Channel
  2. -no-: Note
  3. -pi-: Pitch
  4. -f: Fractional pitch

These components underscore the file format’s focus on assigning precise pitch data to specific MIDI channels and note numbers.

Background: MIDI 2.0 Pitch 7.25

In MIDI 2.0, Registered Per-Note Controller #3: Pitch 7.25 provides a high-resolution method for defining pitch beyond standard 12-tone equal temperament (12-EDO). The 32-bit data field for Pitch 7.25 is split into:

  • 7 bits for the integer part (the “traditional” note number in semitones).
  • 25 bits for the fractional part of a semitone.

This gives 2^7 = 128 distinct note values (as in MIDI 1.0), each further divided into 2^25 microsteps, resulting in a total of 402,653,184 equal divisions per octave (12 semitones × 2^25). This extreme resolution allows for microtonal tunings with a precision of 1.49 × 10^-6 cents.

File Format

A Chanopif (.cnpf) file is a plain-text file containing a series of lines. Each line follows the pattern:

channel_base10 noteNumber_base16 pitch_base16.fractionalPitch_base32

Where:

channel_base10

  • MIDI channel index, ranging from 1 to 256 in MIDI 2.0 (or 1 to 16 in MIDI 1.0).

noteNumber_base16

  • The MIDI note number expressed in hexadecimal, ranging from 00 to 7F.

pitch_base16

  • The 7-bit integer part (in hexadecimal) for semitone pitch, ranging from 00 to 7F.

fractionalPitch_base32

  • A 25-bit fractional part for microtonal precision, expressed in base 32 using the characters 0–9 and A–V. This base-32 representation spans values from 00000 (zero fraction) up to a maximum of VVVVV, that encodes all 2^25 subdivisions of a semitone. Each of the five characters encodes a 5-bit segment of the 25-bit word, with the total being 5×5=25 bits.

Exemple

An example line might be:

16 7F 7F.VVVVV

16 = MIDI channel 16

7F = MIDI note number in hex (127 in decimal)

7F.VVVVV :

  • 7F = pitch part in hex (127 in decimal)
  • VVVVV = fractional part in base 32 (33554431 in decimal)

Syntax

File identification and version declaration

The first line of a Chanopif file must declare the format and version to ensure compatibility:

chanopif version ?.?.?

Metadata support

Metadata is optional but, if included, should appear on the second line for quick identification without needing to scan the entire file. YAML is used, and fields are open-ended.

<meta>
YAML content
</meta>

Comments

Use # to insert a comment. Comments are ignored by the parser and do not affect the file's execution. They can be used to provide explanations or annotations within the file.

Nota bene: YAML metadata only supports inline comment.

# Inline comment

Tuning control

As described above:

channel_base10  noteNumber_base16  pitch_base16.fractionalPitch_base32

Upon loading a Chanopif file, all notes start in an inactive state. As each line is read, the specified note on the given channel becomes active (or is updated if already active) with its assigned pitch and fractional pitch. After the entire file is processed, any notes that have not been defined remain inactive.

To calculate frequencies, the parser uses this formula:

frequency = 440 * 2^(((pitch_decimal - 69) + (fractional_pitch_decimal / (2^25))) / 12)
  • pitch_decimal is the 7-bit pitch portion, represented in hexadecimal within Chanopif, and converted internally to a value between 0 and 127.
  • fractional_pitch_decimal is the 25-bit fractional portion, represented in base 32 within Chanopif, and converted internally to a value between 0 and 2^25 - 1.

Purpose and Implementation

Chanopif’s primary objective is to facilitate unambiguous, universal microtonal tunings within the MIDI 2.0 ecosystem. By standardizing on tuning per channel and 402,653,184-EDO, Chanopif ensures that any tuning, any note pitch, can be represented consistently in .cnpf files. Key goals and benefits include:

  • Overcoming 128-Note Limitations: By combining multiple channels (up to 256 in MIDI 2.0), each with fully customized tuning for every note, composers can effectively bypass the traditional 128-note limitation of MIDI. This is especially beneficial for large-scale works requiring extensive microtonal ranges.
  • Flexibility: By assigning independant tuning configurations per channel, it becomes possible to create scales with a large number of notes, even those that do not rely on octave equivalences.
  • High Precision: At around 1.49 × 10^-6 cents per step, the resolution far exceeds what the human ear can typically discern, making it suitable for studio recording, live performance, or any scenario requiring advanced microtonal control. At 20000 Hz, the phase difference between two adjacent pitches is approximately 16 hours.
  • Data Efficiency: By using the most concise syntax possible, compressing 7-bit words in hexadecimal and 25-bit words into 5 letters of 5-bit (base 32), it ensures optimal space savings in storage and transmission.
  • Compatibility: The format complies with the MIDI 2.0 standard, fully supporting the 7.25 pitch attribute for enhanced musical expression and precision.

Significance

  • Standardized Microtonal Implementation: By adopting a consistent 402,653,184-EDO approach, Chanopif eliminates ambiguity over how fractional pitches are interpreted.
  • Widespread Applications: Chanopif can be used to compose music that extends beyond the standard 128-note limit, allowing for large tuning systems, such as a full eight-octave 72-EDO scale (576 notes required) with optimal Riemann Zeta stretch (no-octave equivalence required). It also enables the development of new instruments, encourages experimentation with alternative scales, and supports hyper-accurate tuning for classical, jazz, electronic, and many other musical styles.
  • Future-Proof: Chanopif is designed to scale with evolving MIDI technology, leveraging the expanded channel range (up to 256) and high-definition capabilities of MIDI 2.0.

Examples

Here is a Chanopif file coding for a 380zpi scale (72-EDO Zeta stretch) spanning eight pseudo-octaves:

Here is another Chanopif file describing a Carlos Alpha scale covering fourteen fifth-equivalences:

Todo: Generate both files

Upload the files and insert their respective links here.

See Also

MIDI 2.0 Specification – Official documentation covering new controllers, higher resolution, and enhanced expressiveness.

MIDI Tuning Standard (MTS) – Precursor to Pitch 7.25, offering microtuning capabilities in MIDI 1.0.

MTS-ESP

Disclaimer : Chanopif is a proposed format. Implementation details may vary based on hardware and software support for MIDI 2.0 Pitch 7.25. For the most accurate and up-to-date technical specifications, consult official MIDI 2.0 documentation.