Skip to content

Takes an input array of named pitches to Hz frequencies and outputs the dyads within that pitch class which produce difference tones that are the closest to approximating those same frequencies.

Notifications You must be signed in to change notification settings

luphoria/difference-tone-classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

=== DIFFTONEGEN ===
luphoria

This nodejs program takes an input array of named pitches to Hz frequencies and outputs the dyads within that pitch class which produce difference tones that are the closest to approximating those same frequencies. 

== EXAMPLE ==
Here is an example limited `allPitches.json`: 
```json
{
    "A3": 220.0000,
    "B3": 246.9417,
    "C4": 261.6256,
    "D4": 293.6648,
    "E4": 329.6276,
    "F4": 349.2282,
    "G4": 391.9954,
    "A4": 440.0000,
    "E5": 659.2551,
    "A5": 880.0000
  }
```
After running the program, it outputs this: 
```json
{
  "A3": {
    "A3,A3": 0,
    "A3,A4": 220,
    [...]
    "G4,A4": 48.005,
    "A4,E5": 219.255,
    "E5,A5": 220.745
  },
  "B3": {},
  "C4": { "G4,E5": 267.26 },
  "D4": { "F4,E5": 310.027 },
  "E4": { "E4,E5": 329.628 },
  "F4": { "D4,E5": 365.59 },
  "G4": { "B3,E5": 412.313, "C4,E5": 397.629 },
  "A4": { "A4,A5": 440, "A3,E5": 439.255, "F4,A5": 530.772, "G4,A5": 488.005 },
  "E5": {
    "A3,A5": 660,
    "B3,A5": 633.058,
    "C4,A5": 618.374,
    "D4,A5": 586.335,
    "E4,A5": 550.372
  },
  "A5": {}
}
```
As you can see, the program calculates the difference tone of each dyad, and then sorts them by how closely they approximate each of the original frequencies. So, to create a difference tone of ~G4 with this limited set, you could use a dyad of B3 and E5 or C4 and E5. 

== USAGE ==
Edit `allPitches.json` with your desired pitches and frequencies in hz (the included file is 12EDO, A=440, range D#3 to E6). The Note naming conventions do not matter. 
Run `difftoneGen.js` with `node diffToneGen.js`. It should output `out.json`. 

== TODO ==
 - Numeric sort for the output frequencies. Maybe switch around the K:V for dyads:frequency as well. 
 - Possibly an option to separate the input pitch class and the targeted output pitch class. Seems like too niche an issue for me to care. 
 - Clean it up. This will never ever ever get done. 

About

Takes an input array of named pitches to Hz frequencies and outputs the dyads within that pitch class which produce difference tones that are the closest to approximating those same frequencies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published