keyboard_map: Create Keyboard Map

View source: R/cps_functions.R

keyboard_mapR Documentation

Create Keyboard Map

Description

Creates a keyboard map

Usage

keyboard_map(scale_table, middle_c_octave = 4)

Arguments

scale_table

a scale table from ps_scale_table, cps_scale_table, or et_scale_table

middle_c_octave

octave number for middle C. There are varying conventions for the octave number for middle C. The default for this function is 4, but other software can use 3 or even some other number

Details

The function is currently hard-coded to compute the map so that middle C with frequency .FREQ_MIDDLE_Cis mapped to MIDI note number .NN_MIDDLE_C and scale degree 0. With the current constants this is the same as it is on 12EDO with A440 on note 69. This note is 6000 cents above MIDI note number 0 in 12EDO.

Normally you would only use this to remap a keyboard to a scale with more than 12 notes per octave. For scales with 12 or fewer notes to the octave, it's easier to remap all octaves using the offsets computed with offset_matrix!

Value

the keyboard map. This is a data.table with eight columns:

  • note_number: the MIDI note number from .NN_MIN through .NN_MAX

  • name_12edo: note name of the key in 12EDO. This is the key you'd normally press to play this note number

  • octave_12edo: the octave the key normally plays

  • note_name: the note name from the scale table

  • ratio_frac: ratio for the note as a vulgar fraction. Note that for equal tempered scales this is usually an approximation to an irrational number. The algorithm used appears to give six decimal places of accuracy.

  • degree: the scale degree of the note

  • octave: the octave number of the note

  • freq: the frequency in Hz

  • cents: cents above lowest MIDI note .NN_MIN, which has frequency .FREQ_MIN.

  • ref_keyname: some synthesizers, including the Korg Minilogue XD, let you retune a key as an offset in cents from another reference key. This column is the name of that reference key.

  • ref_octave: the octave number of the reference key

  • ref_offset: the offset in cents from the reference key

Examples


# make sure we can print a whole keyboard map
options(max.print = 2000)

eikosany <- cps_scale_table(root_divisor = 33)
print(eikosany_keyboard_map <- keyboard_map(eikosany), nrows = 128)

# 12-EDO for sanity check
print(vanilla_keyboard_map <- keyboard_map(et_scale_table()), nrows = 128)

# check middle C setting
print(
  eikosany_keyboard_map_c3 <-
    keyboard_map(cps_scale_table(root_divisor = 33), middle_c_octave = 3), nrows = 128)

# Bohlen-Pierce (13 equal divisions of a perfect twelfth aka "tritave")
bohlen_pierce_et_scale <- et_scale_table(bohlen_pierce_et_names, period = 3)
print(bohlen_pierce_et_map <-
  keyboard_map(bohlen_pierce_et_scale), nrows = 128)

AlgoCompSynth/eikosany documentation built on Nov. 25, 2024, 5:22 p.m.