While inspecting the code of the main source of the library, edo.js, I realized that a file with the same name is located in two places /edo.js and scripts/edo.js.
I was wondering about the difference between these, and found that they are almost exact duplicates, except for some small portions of the code.
See diff
```diff
diff --git a/edo.js b/scripts/edo.js
index b11068d..524ddfb 100644
--- a/edo.js
+++ b/scripts/edo.js
@@ -430,47 +430,9 @@ class EDO {
* edo.convert.cents_to_ratio(700)
* // returns 1.4983070768766815*/
cents_to_ratio: (cents) => {
- if(Array.isArray(cents)) {
- return cents.map(e=>this.convert.cents_to_ratio(e))
- }
return Math.pow(2, cents / 1200)
},
- cents_to_simple_ratio: (cents,limit=17) => {
- if(Array.isArray(cents)) return cents.map(c=>this.convert.cents_to_simple_ratio(c,limit))
- cents = this.mod(cents,1200)
- if(cents==0) {
- return {
- cents: 0,
- cents_in_octave: 0,
- value: 1,
- diff_in_octave: 0,
- ratio: '1/1',
- original: 0
- }
- }
-
- let SR = this.get.simple_ratios(limit,true)
- let min
- for (let key of Object.keys(SR)) {
-
- if(min) {
- let diff_in_octave = Math.abs(SR[key].cents_in_octave-cents)
- let diff_min = Math.abs(SR[min].cents_in_octave-cents)
- if(diff_in_octaveDownloads / saves an SVG file with the contents of a container
- *
Note: all of the graphics made with this library create SVG elements, so just pass the same ID that you used to create the graphic in the first place
- *
- * @param {String} container_id - The ID of a container that has one or more SVG elements in it.
- * @memberOf EDO#export
- * @example
- * let edo = new EDO()
- * //Create a necklace graphic
- * edo.show.necklace('container', [0,2,4,5,7,9,11])
- *
- * //Save the graphic
- * edo.export.svg('container') //downloads the necklace
- */
svg: (container_id) => {
if (environment == "server") return console.log("This is only support when run on client-side")
let el = document.getElementById(container_id)
@@ -942,36 +890,6 @@ class EDO {
return ((180-diff1/12*360)/2) + ((180-diff2/12*360)/2)
},
- /**
Given an array of scale degrees in cents, returns a Scale Object in the edo that best describes the pitches.
- *
- *
If a, b, and c, are vertices of a triangle (trichord) on a necklace. This function returns the angle abc. That is, the angle node b has with a and c.
- * @param {Array} scale_in_cents - The scale in question represented in cents
- * @param {Number} begin_edo - The smallest EDO to consider
- * @param {Number} end_edo - The largest EDO to consider
- * @returns {Scale} A scale in the best fitting EDO
- * @memberOf EDO#get
- * @example
- * let edo = new EDO() // define a tuning system
- * edo.get.best_edo_from_cents([0,200,350,500,700,900,1100])
- * //returns the Scale Object [0,4,7,10,14,18,22] in a 24EDO context
- */
- best_edo_from_cents: (scale_in_cents,begin_edo=scale_in_cents.length+2,end_edo=24) => {
- let cents = scale_in_cents
- let diff = Infinity
- let min_edo = Infinity
- for (let i = begin_edo; i <= end_edo; i++) {
- let ed = new EDO(i)
- let edo_app = ed.get.notes_from_cents(cents)
- let edo_diff = edo_app.reduce((ag,e)=>ag+Math.abs(e.diff),0)
- if (edo_diffe.note))
- },
-
/** Returns the [x,y] coordinates of the nodes of the given pitches.
* pitch
* @param {Array | Number} pitch - A pitch, or an array of pitches
@@ -1491,7 +1409,7 @@ class EDO {
* @param {Array} arr - An array with elements
* @param {Number} k=2 - The number of elements in each returned permutation
* @returns {Array}
- * @memberOf EDO#get
+ * @memberOf Scale#get
* @example
* edo.get.n_choose_k([1,3,5,7],k=3)
* //returns [ [ 1, 3, 5 ], [ 1, 3, 7 ], [ 1, 5, 7 ], [ 3, 5, 7 ] ]
@@ -1512,40 +1430,6 @@ class EDO {
return results
},
- /**
Returns the closest approximation within the current EDO from a list of pitches in cents and the difference between the EDO version to the original in cents.
- * @param {Array} cents - A list of pitches as cents
- * @returns {Array
It seems that edo.js has slightly more documentation, and a few changes in the actual source.
For the most part, these are +7000 lines of duplicated source code.
Unless there is a strong argument for having both, please remove one (scripts/edo.js?).
This issue is related to the following review: https://github.com/openjournals/joss-reviews/issues/3784
While inspecting the code of the main source of the library,
edo.js
, I realized that a file with the same name is located in two places/edo.js
andscripts/edo.js
.I was wondering about the difference between these, and found that they are almost exact duplicates, except for some small portions of the code.
See diff
```diff diff --git a/edo.js b/scripts/edo.js index b11068d..524ddfb 100644 --- a/edo.js +++ b/scripts/edo.js @@ -430,47 +430,9 @@ class EDO { * edo.convert.cents_to_ratio(700) * // returns 1.4983070768766815*/ cents_to_ratio: (cents) => { - if(Array.isArray(cents)) { - return cents.map(e=>this.convert.cents_to_ratio(e)) - } return Math.pow(2, cents / 1200) }, - cents_to_simple_ratio: (cents,limit=17) => { - if(Array.isArray(cents)) return cents.map(c=>this.convert.cents_to_simple_ratio(c,limit)) - cents = this.mod(cents,1200) - if(cents==0) { - return { - cents: 0, - cents_in_octave: 0, - value: 1, - diff_in_octave: 0, - ratio: '1/1', - original: 0 - } - } - - let SR = this.get.simple_ratios(limit,true) - let min - for (let key of Object.keys(SR)) { - - if(min) { - let diff_in_octave = Math.abs(SR[key].cents_in_octave-cents) - let diff_min = Math.abs(SR[min].cents_in_octave-cents) - if(diff_in_octaveNote: all of the graphics made with this library create SVG elements, so just pass the same ID that you used to create the graphic in the first place
- * - * @param {String} container_id - The ID of a container that has one or more SVG elements in it. - * @memberOf EDO#export - * @example - * let edo = new EDO() - * //Create a necklace graphic - * edo.show.necklace('container', [0,2,4,5,7,9,11]) - * - * //Save the graphic - * edo.export.svg('container') //downloads the necklace - */ svg: (container_id) => { if (environment == "server") return console.log("This is only support when run on client-side") let el = document.getElementById(container_id) @@ -942,36 +890,6 @@ class EDO { return ((180-diff1/12*360)/2) + ((180-diff2/12*360)/2) }, - /**Given an array of scale degrees in cents, returns a Scale Object in the edo that best describes the pitches.
- * - *If
- * @param {Arraya
,b
, andc
, are vertices of a triangle (trichord) on a necklace. This function returns the angleabc
. That is, the angle node b has with a and c.Returns the closest approximation within the current EDO from a list of pitches in cents and the difference between the EDO version to the original in cents.
- * @param {ArrayIt seems that
edo.js
has slightly more documentation, and a few changes in the actual source.For the most part, these are +7000 lines of duplicated source code.
Unless there is a strong argument for having both, please remove one (scripts/edo.js?).