new DHC( id, harmonicarium )

Description

The Dynamic Harmonics Calculator class

This is the computational kernel for the frequency/midicent tables.
Manage an route the communications from and to the other App components.

Parameters
Name Type Description
id string

The DHC id, in format harmonicariumID-dhcID (eg. '1-0')

harmonicarium HUM

The HUM instance to which the this DHC must refer

Details

Classes


new Xtone()


new DHCsettings( preset )

Members


harmonicarium :HUM

Description

The HUM instance

Details

id :string

Description

The id of this DHC instance

Details
string

settings :HUM.DHC#DHCsettings

Description

DHC Settings

Details

tables :Object

Description

DHC Tables

Properties
Name Type Description
ctrl CtrlKeymap

The current Controller Keymap

ft Object.<xtnum, HUM.DHC#Xtone>

The current Fundamental Tones table

ht Object.<xtnum, HUM.DHC#Xtone>

The current Harmonic/Subharmonic Tones table

reverse Object

Reverse tables namespace

Name Type Description
ft Object.<midinnum, xtnum>

Reverse Fundamental Tones table

ht Object.<midinnum, xtnum>

Reverse Harmonic/Subharmonic Tones table

Details
Object

uiElements :Object

Description

UI HTML elements

Properties
Name Type Description
fn Object.<string, HTMLElement>

Functional UI elements

in Object.<string, HTMLElement>

Input UI elements

out Object.<string, HTMLElement>

Output UI elements

Details
Object

registeredApps :Map.<Object, string>

Description

Registered Apps

The key of each record is an app Object and the value is the metod that must be invoked
to send messages towards the app.

Details
Map.<Object, string>

hstack :HUM.Hstack

Description

The Hstack instance

Details

synth :HUM.Synth

Description

The Synth instance

Details

midi :HUM.midi.MidiHub

Description

The MidiHub instance

Details

hancock :HUM.Hancock

Description

The Hstack instance

Details

pipe :Object

Description

Piper's default settings

Properties
Name Type Description
maxLenght number

How many steps has the Pipe

queue Array.<HUM.DHCmsg>

Last HT MIDI Note-ON messages received

pipe Array.<HUM.DHCmsg>

MIDI Note-ON messages stored into the Pipe

currStep number

Last step played by the Piper

currTone HUM.DHCmsg

Last fake MIDI Note-ON message send

Details
Object

playQueue :Object

Description

Queues for FT/HT playing and muting management

Properties
Name Type Description
ft Array.<HUM.DHCmsg>

Queue for FT key-press tracking

ht Array.<HUM.DHCmsg>

Queue for HT key-press tracking

Details
Object

ctrlKeymapPreset :HUM.CtrlKeymapPreset

Description

The container for all the Controller keymap presets

Details

backendUtils :BackendUtils

Description

The Backend Utils instance

Details
BackendUtils

Methods


_init()

Description

Initialize the new instance of DHC

Details

registerApp( app, method, priority )

Description

Register a new App (module)

Parameters
Name Type Description
app Object

The instance of the app to be registered

method string

The name of the method to use to send messages

priority number

The priority with which the registered app will receive messages

Details

sendMessageToApps( dhcMsg )

Description

Send a DHCmsg message to all the registered apps

Parameters
Name Type Description
dhcMsg HUM.DHCmsg

The message to send

Details

initTables()

Description

Recompile FT & HT tables in the right order

Details

createFTtable()

Description

Recompile the Fundamental Tones (FT) table

Details

createHTtable( fundamental )

Description

Recompile the Harmonic/Subarmonic Tones (HT) table

Parameters
Name Type Description
fundamental hertz

The tone on which to build the table, expressed in hertz (Hz)

Details

getFM( method ) → {hertz}

Description

Get the Fundamental Mother (FM) from the UI input

Parameters
Name Type Description
method 'mc' | 'hz'

Method to use to get the FM

Returns
  • Frequency expressed in hertz (Hz)
Details

setFM( hz )

Description

Set the Fundamental Mother (FM) and re-init the tone tables

Parameters
Name Type Description
hz hertz

Frequency expressed in hertz (Hz)

Details

printFundamentalMother( hz, mc )

Description

Print the Fundamental Mother (FM) data to the UI output

Parameters
Name Type Description
hz hertz

Frequency expressed in hertz (Hz)

mc midicent

MIDI note number expressed in midicent

Details

switchFTsys( sys [, sys_hs ], init )

Description

Switch the FT TUNING SYSTEM (called when UI is updated)

Parameters
Name Type Attributes Default Description
sys 'nedx' | 'hs'

FTs tuning method; 'nedx' (equal temperament) or 'hs' (harm/subharm)

sys_hs 'natural' | 'sameOctave' <optional>
false

FTs Harm/Subharm tuning method; 'natural' (no transposition) or 'sameOctave' (to the same octave)

init boolean false

If the method has been called by the ._init() method

Details

setNEDX()

Description

Set the nEDx (called when UI is updated)

Details

transposeFThs( ratio, type )

Description

Transpose FT under harmonics/subharmonics Tuning System (called when UI is updated)

Parameters
Name Type Description
ratio tratio

The ratio for the transposition

type tonetype

The tone type

Details

transposeHT( ratio, type, octave )

Description

Transpose HT (sub)harmonics (called when UI is updated)

Parameters
Name Type Description
ratio tratio

The ratio with which to compute the transposition

type 'h' | 's'

Type of transposition; 'h' for harmonics or 's' for subharmonics

octave boolean

If it's an octave transposition or not.

If it's true, the 'ratio' should be 2 (for octave up) or 0.5 (for octave down).

Details

updateKeymapPreset()

Description

Update the preset list according to the selected FTs Tuning System

Details

loadKeymapPreset( changeEvent )

Description

Load a Controller keymap from 'ctrlKeymapPreset' according to the selection on UI

Parameters
Name Type Description
changeEvent Event

Change HTML event on 'select' element (ctrl keymap dropdown)

Details

handleKeymapFile( changeEvent )

Description

On loading the Controller Keymap file

Parameters
Name Type Description
changeEvent Event

HTML change event on 'input' element (ctrl keymap file uploader)

Details

readKeymapFile( file )

Description

Initialize the reading process of the Controller Keymap file

Parameters
Name Type Description
file File

The file to be read

Details

processKeymapData( data, name )

Description

Build the Controller Keymap table on the incoming raw data from .hcmap file

Parameters
Name Type Description
data string

The text content of the Controller keymap file

name string

The filename

Details

keymap2Html()

Description

Create an HTML table from the controller keymap and write it to the UI under a modal element

Details

playFT( dhcMsg )

Description

Play a Fundamental Tone

Parameters
Name Type Description
dhcMsg HUM.DHCmsg

The message containing the FT to be played

Details

muteFT( dhcMsg )

Description

Stop playing a Fundamental Tone

Parameters
Name Type Description
dhcMsg HUM.DHCmsg

The message containing the FT to be muted

Details

playHT( dhcMsg )

Description

Play a Harmonic/Subharmonic Tone

Parameters
Name Type Description
dhcMsg HUM.DHCmsg

The message containing the HT to be played

Details

muteHT( dhcMsg )

Description

Stop playing a Harmonic/Subharmonic Tone

Parameters
Name Type Description
dhcMsg HUM.DHCmsg

The message containing the HT to be muted

Details

panic()

Description

Force to stop playing all Fundamental and Harmonic/Subharmonic Tones

Details

piper( dhcMsg )

Description

Store a play-HT message into the Piper's queue

Parameters
Name Type Description
dhcMsg HUM.DHCmsg

The message containing the HT to be piped

Details

piping( state )

Description

Play or mute the next HT available in the piper's queue.

Usually when HT0 is pressed (or released).

Parameters
Name Type Description
state 0 | 1

Note ON/OFF; 1 is ON (play), 0 is OFF (mute)

Details

initPipeQueue( type )

Description

Experimental function for dynamic default/preloaded piper melody.

Fill the Piper's queue with a sequence of HTs.

Parameters
Name Type Description
type 'h' | 's' | 'hs'

The HTs scale type of the current Controller keymap

Details

- The preloaded Pipe must use only available keys


bendXtone( xtObj ) → {HUM.DHC#Xtone}

Description

Apply the current controller pitchbend amount (if present) to a Xtone object and return a pitch-bent copy of it.

Parameters
Name Type Description
xtObj HUM.DHC#Xtone

FT or HT object of the tone to bend

Returns
  • The pitch-bent object
Details

initUImonitors()

Description

Update all parts of the UI with the last computed or set values.
Send the 'init' message to all the redistered Apps.

Details

dhcMonitor( type, xtNum )

Description

Monitor UI

Parameters
Name Type Description
type tonetype

If the tone is a FT or HT

xtNum xtnum

FT or HT relative tone number

Details

_initUI()

Description

Initialize the DHC UI controllers

Details

nameToMidiNumber( mode, note ) → {midinnum}

Description

Parse a note name string to get the MIDI note number

Parameters
Name Type Description
mode 'hancock' | 'ui' | 'scientific'

The method in which the 'note' should be interpreted.

note string

The note name in format [A-G]#?-?\d+. E.g. C0, A#4, G-3, D#-1

Returns
  • MIDI note number
Examples
'hancock' C0 == 0 midicent == 0 midinnum
			'scientific' C0 == 12 midicent == 12 midinnum
			'ui' C0 == // depends on Middle C setting (DHCsettings.global.middle_c) 
Details

midiNumberToNames( midikey ) → {Array.<string, string, boolean, string>}

Description

Convert a MIDI note number to an array containing 'hancock', 'ui' and 'scientific' note name,
plus the information if the key on the piano should be black or white.

Parameters
Name Type Description
midikey midinnum

MIDI note number (integer)

Returns
  • An array with Hancock, UI and Scientific note name, and if the key is white or black
Details

mcToName( mc ) → {Array.<string, number, string, boolean>}

Description

UI Util to get the UI note name +/- cents from given midicent

Parameters
Name Type Description
mc midicent

Pitch in midicent (float)

Returns
  • Array containing [note name, +/- sign, cents, black key y/n]
Details

mcToNameString( mc ) → {string}

Description

Util to get the full string of UI note name +/- cents

Parameters
Name Type Description
mc midicent

Pitch in midicent (float)

Returns
  • The compliled string; e.g. D#3 -45ยข;
Details

<static> mcToFreq( mc ) → {hertz}

Description

From MIDI note number to frequency (Hz)

Parameters
Name Type Description
mc midicent

MIDI note number expressed in midi.cents

Returns
  • Frequency expressed in hertz (Hz)
Details

<static> freqToMc( freq ) → {midicent}

Description

From frequency (Hz) to MIDI note number

Parameters
Name Type Description
freq hertz

Frequency expressed in hertz (Hz)

Returns
  • MIDI note number expressed in midicent
Details

<static> compute_nEDx( relativeTone, unit, division, masterTuning ) → {hertz}

Description

Calculate the n-EDx ("free" equal temperament) of a relative tone

Parameters
Name Type Description
relativeTone number

Relative number of the "step" in the scale (should be integer)

unit number

Ratio unit (must be greater than zero)

division number

Equal divisions of the ratio unit (must be greater than zero)

masterTuning hertz

Reference frequency expressed in hertz (Hz)

Returns
  • Frequency expressed in hertz (Hz)
Details

<static> uniqArray( arrArg ) → {Array.<number>}

Description

Remove duplicated values on the array passed via the argument

Parameters
Name Type Description
arrArg Array.<number>

Array of numbers

Returns
  • Uniquified array
Details