Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(props) {
super(props)
let song = this.props.song
this.notesCountInputRef = React.createRef()
this.beatsLengthInputRef = React.createRef()
this.codeInputRef = React.createRef()
this.fieldUpdaters = {
code: e => this.updateCode(e.target.value)
}
let initial = song
if (!song) {
initial = readConfig("wip:newSong")
// render the initial song
if (initial) {
window.setTimeout(() => {
if (this.state.code == initial.code) {
if (this.props.onCode) {
this.props.onCode(initial.code)
}
}
}, 0)
}
}
this.state = {
song,
newSong: !song,
loading: false,
constructor(props) {
super(props)
let device = readConfig("defaults:outputDeviceType") || "none"
let midiOutputChannel
if (device == "internal") {
midiOutputChannel = SampleOutput.getInstance()
}
this.state = {
outputDeviceType: device,
forwardMidi: readConfig("defaults:forwardMidi") == 1,
midiOutputChannel
}
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess().then(
midi => {
this.setState({midi: midi})
this.loadDefaultSettings()
},
error => console.warn("failed to get MIDI"))
}
}
loadDefaultSettings() {
let defaultMidiInput = readConfig("defaults:midiIn")
if (defaultMidiInput) {
let idx = 0
for (let input of this.midiInputs()) {
if (input.name == defaultMidiInput) {
this.setInput(idx)
}
idx++
}
}
}
constructor(props) {
super(props)
let device = readConfig("defaults:outputDeviceType") || "none"
let midiOutputChannel
if (device == "internal") {
midiOutputChannel = SampleOutput.getInstance()
}
this.state = {
outputDeviceType: device,
forwardMidi: readConfig("defaults:forwardMidi") == 1,
midiOutputChannel
}
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess().then(
midi => {
this.setState({midi: midi})
this.loadDefaultSettings()
updateWip(update) {
if (!this.state.newSong) {
return false
}
let wip = readConfig("wip:newSong") || {}
wip = Object.assign({}, wip, update)
writeConfig("wip:newSong", wip)
return true
}