forked from soundio/soundstage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sequencer accepts data and parses events
- Loading branch information
Showing
12 changed files
with
232 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
function throwParseFloat32() { | ||
throw new Error('Cannot parse value "' + value + '" as Float32'); | ||
} | ||
|
||
export default function parseFloat32(value) { | ||
const number = Math.fround(value); | ||
return Number.isNaN(number) ? | ||
throwParseFloat32() : | ||
number ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
function throwParseNumber() { | ||
throw new Error('Cannot parse value "' + value + '" as Number'); | ||
} | ||
|
||
/** | ||
parseFloat() | ||
Like JavaScript's `parseFloat`, but with a check for `NaN`. | ||
**/ | ||
|
||
export default function parseFloat64(value) { | ||
const number = Number(value); | ||
return Number.isNaN(number) ? | ||
throwParseNumber() : | ||
number ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
import id from '../../../fn/modules/id.js'; | ||
import overload from '../../../fn/modules/overload.js'; | ||
import toType from '../../../fn/modules/to-type.js'; | ||
import { toNoteNumber } from '../../../midi/modules/data.js'; | ||
import parseFloat from './parse-float-64.js'; | ||
|
||
const rdigit = /^\d/; | ||
|
||
export default overload(toType, { | ||
'number': id, | ||
'string': (value, tuning = 440) => ( | ||
rdigit.test(value) ? parseFloat(value) : toNoteNumber(value) | ||
) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.