Skip to content

Commit

Permalink
update annotations outside of animation thread. remove MIDI input menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
charlieroberts committed Jan 30, 2018
1 parent ea46971 commit fddcac1
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 65 deletions.
52 changes: 31 additions & 21 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3743,6 +3743,15 @@ let Scheduler = {
return time
},

runSoon( evt ) {

try{
evt.func()
}catch(e) {
console.log( 'annotiation error:', e.toString() )
}
},

run( timestamp, dt ) {
let nextEvent = this.queue.peek()
//if( nextEvent === undefined ) return
Expand All @@ -3752,12 +3761,13 @@ let Scheduler = {
// remove event
this.queue.pop()

try{
nextEvent.func()
}catch( e ) {
console.log( e )
Gibber.Environment.error( 'annotation error:', e.toString() )
}
setTimeout( ()=> this.runSoon( nextEvent ) )
//try{
// nextEvent.func()
//}catch( e ) {
// console.log( e )
// Gibber.Environment.error( 'annotation error:', e.toString() )
//}

// call recursively
this.run( timestamp )
Expand Down Expand Up @@ -8392,7 +8402,7 @@ let Gibber = {
Gibber.Gen.lastConnected.push( seq.timings )
}

return obj[ methodName ]
return seq
}

obj[ methodName ].seq.delay = v => obj[ methodName ][ lastId ].delay( v )
Expand Down Expand Up @@ -9096,9 +9106,9 @@ const MIDI = {
const lastMIDIInput = localStorage.getItem('midi.input'),
lastMIDIOutput = localStorage.getItem('midi.output')

if( lastMIDIInput !== null && lastMIDIInput !== undefined ) {
this.selectInputByName( lastMIDIInput )
}
//if( lastMIDIInput !== null && lastMIDIInput !== undefined ) {
// this.selectInputByName( lastMIDIInput )
//}
if( lastMIDIOutput !== null && lastMIDIOutput !== undefined ) {
this.selectOutputByName( lastMIDIOutput )
}
Expand All @@ -9110,23 +9120,23 @@ const MIDI = {
},

createInputAndOutputLists( midiAccess ) {
let optin = document.createElement( 'option' )
optin.text = 'none'
//let optin = document.createElement( 'option' )
//optin.text = 'none'
let optout = document.createElement( 'option' )
optout.text = 'none'
MIDI.midiInputList.add( optin )
//MIDI.midiInputList.add( optin )
MIDI.midiOutputList.add( optout )

MIDI.midiInputList.onchange = MIDI.selectInputViaGUI
//MIDI.midiInputList.onchange = MIDI.selectInputViaGUI
MIDI.midiOutputList.onchange = MIDI.selectOutputViaGUI

const inputs = midiAccess.inputs
for( let input of inputs.values() ) {
const opt = document.createElement( 'option' )
opt.text = input.name
opt.input = input
MIDI.midiInputList.add( opt )
}
//const inputs = midiAccess.inputs
//for( let input of inputs.values() ) {
// const opt = document.createElement( 'option' )
// opt.text = input.name
// opt.input = input
// MIDI.midiInputList.add( opt )
//}

const outputs = midiAccess.outputs
for( let output of outputs.values() ) {
Expand Down
54 changes: 32 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@

<div class="microlib_tabs_tab" data-title="midi">
<div id='MIDIView'>
<label>select MIDI input:</label><br><select id='midiInputSelect'></select><br>
<!--<label>select MIDI input:</label><br><select id='midiInputSelect'></select><br>-->
<label>select MIDI output:</label><br><select id='midiOutputSelect'></select><br>
<!--<label>cc modulation output rate (in Hz):</label><br>-->
<!--<input id='modulationRate' value=60></input><br>-->
Expand Down Expand Up @@ -4565,6 +4565,15 @@
return time
},

runSoon( evt ) {

try{
evt.func()
}catch(e) {
console.log( 'annotiation error:', e.toString() )
}
},

run( timestamp, dt ) {
let nextEvent = this.queue.peek()
//if( nextEvent === undefined ) return
Expand All @@ -4574,12 +4583,13 @@
// remove event
this.queue.pop()

try{
nextEvent.func()
}catch( e ) {
console.log( e )
Gibber.Environment.error( 'annotation error:', e.toString() )
}
setTimeout( ()=> this.runSoon( nextEvent ) )
//try{
// nextEvent.func()
//}catch( e ) {
// console.log( e )
// Gibber.Environment.error( 'annotation error:', e.toString() )
//}

// call recursively
this.run( timestamp )
Expand Down Expand Up @@ -9214,7 +9224,7 @@
Gibber.Gen.lastConnected.push( seq.timings )
}

return obj[ methodName ]
return seq
}

obj[ methodName ].seq.delay = v => obj[ methodName ][ lastId ].delay( v )
Expand Down Expand Up @@ -9918,9 +9928,9 @@
const lastMIDIInput = localStorage.getItem('midi.input'),
lastMIDIOutput = localStorage.getItem('midi.output')

if( lastMIDIInput !== null && lastMIDIInput !== undefined ) {
this.selectInputByName( lastMIDIInput )
}
//if( lastMIDIInput !== null && lastMIDIInput !== undefined ) {
// this.selectInputByName( lastMIDIInput )
//}
if( lastMIDIOutput !== null && lastMIDIOutput !== undefined ) {
this.selectOutputByName( lastMIDIOutput )
}
Expand All @@ -9932,23 +9942,23 @@
},

createInputAndOutputLists( midiAccess ) {
let optin = document.createElement( 'option' )
optin.text = 'none'
//let optin = document.createElement( 'option' )
//optin.text = 'none'
let optout = document.createElement( 'option' )
optout.text = 'none'
MIDI.midiInputList.add( optin )
//MIDI.midiInputList.add( optin )
MIDI.midiOutputList.add( optout )

MIDI.midiInputList.onchange = MIDI.selectInputViaGUI
//MIDI.midiInputList.onchange = MIDI.selectInputViaGUI
MIDI.midiOutputList.onchange = MIDI.selectOutputViaGUI

const inputs = midiAccess.inputs
for( let input of inputs.values() ) {
const opt = document.createElement( 'option' )
opt.text = input.name
opt.input = input
MIDI.midiInputList.add( opt )
}
//const inputs = midiAccess.inputs
//for( let input of inputs.values() ) {
// const opt = document.createElement( 'option' )
// opt.text = input.name
// opt.input = input
// MIDI.midiInputList.add( opt )
//}

const outputs = midiAccess.outputs
for( let output of outputs.values() ) {
Expand Down
2 changes: 1 addition & 1 deletion index_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<div class="microlib_tabs_tab" data-title="midi">
<div id='MIDIView'>
<label>select MIDI input:</label><br><select id='midiInputSelect'></select><br>
<!--<label>select MIDI input:</label><br><select id='midiInputSelect'></select><br>-->
<label>select MIDI output:</label><br><select id='midiOutputSelect'></select><br>
<!--<label>cc modulation output rate (in Hz):</label><br>-->
<!--<input id='modulationRate' value=60></input><br>-->
Expand Down
22 changes: 16 additions & 6 deletions js/animationScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ let Scheduler = {
return time
},

runSoon( evt ) {

try{
evt.func()
}catch(e) {
console.log( 'annotiation error:', e.toString() )
}
},

run( timestamp, dt ) {
let nextEvent = this.queue.peek()
//if( nextEvent === undefined ) return
Expand All @@ -33,12 +42,13 @@ let Scheduler = {
// remove event
this.queue.pop()

try{
nextEvent.func()
}catch( e ) {
console.log( e )
Gibber.Environment.error( 'annotation error:', e.toString() )
}
setTimeout( ()=> this.runSoon( nextEvent ) )
//try{
// nextEvent.func()
//}catch( e ) {
// console.log( e )
// Gibber.Environment.error( 'annotation error:', e.toString() )
//}

// call recursively
this.run( timestamp )
Expand Down
2 changes: 1 addition & 1 deletion js/gibber.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ let Gibber = {
Gibber.Gen.lastConnected.push( seq.timings )
}

return obj[ methodName ]
return seq
}

obj[ methodName ].seq.delay = v => obj[ methodName ][ lastId ].delay( v )
Expand Down
28 changes: 14 additions & 14 deletions js/midi.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ const MIDI = {
const lastMIDIInput = localStorage.getItem('midi.input'),
lastMIDIOutput = localStorage.getItem('midi.output')

if( lastMIDIInput !== null && lastMIDIInput !== undefined ) {
this.selectInputByName( lastMIDIInput )
}
//if( lastMIDIInput !== null && lastMIDIInput !== undefined ) {
// this.selectInputByName( lastMIDIInput )
//}
if( lastMIDIOutput !== null && lastMIDIOutput !== undefined ) {
this.selectOutputByName( lastMIDIOutput )
}
Expand All @@ -59,23 +59,23 @@ const MIDI = {
},

createInputAndOutputLists( midiAccess ) {
let optin = document.createElement( 'option' )
optin.text = 'none'
//let optin = document.createElement( 'option' )
//optin.text = 'none'
let optout = document.createElement( 'option' )
optout.text = 'none'
MIDI.midiInputList.add( optin )
//MIDI.midiInputList.add( optin )
MIDI.midiOutputList.add( optout )

MIDI.midiInputList.onchange = MIDI.selectInputViaGUI
//MIDI.midiInputList.onchange = MIDI.selectInputViaGUI
MIDI.midiOutputList.onchange = MIDI.selectOutputViaGUI

const inputs = midiAccess.inputs
for( let input of inputs.values() ) {
const opt = document.createElement( 'option' )
opt.text = input.name
opt.input = input
MIDI.midiInputList.add( opt )
}
//const inputs = midiAccess.inputs
//for( let input of inputs.values() ) {
// const opt = document.createElement( 'option' )
// opt.text = input.name
// opt.input = input
// MIDI.midiInputList.add( opt )
//}

const outputs = midiAccess.outputs
for( let output of outputs.values() ) {
Expand Down

0 comments on commit fddcac1

Please sign in to comment.