unsticking notes when they get stuck
This commit is contained in:
parent
e2f4f5371d
commit
0b7012892f
@ -139,14 +139,12 @@ class KeyboardElement extends events.EventEmitter {
|
|||||||
highlight.classList.remove('active')
|
highlight.classList.remove('active')
|
||||||
setTimeout(() => highlight.remove(), 2000)
|
setTimeout(() => highlight.remove(), 2000)
|
||||||
//and up on the roll
|
//and up on the roll
|
||||||
this._roll.keyUp(noteNum, ai)
|
|
||||||
} else {
|
} else {
|
||||||
// console.log(this._keys[noteNum].querySelector(query))
|
//try again
|
||||||
//try again without ai
|
|
||||||
this.keyUp(noteNum)
|
this.keyUp(noteNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
this._roll.keyUp(noteNum, ai)
|
||||||
}
|
}
|
||||||
|
|
||||||
_getNotePosition(key){
|
_getNotePosition(key){
|
||||||
|
@ -32,7 +32,7 @@ class Keyboard extends events.EventEmitter{
|
|||||||
* The audio key keyboard
|
* The audio key keyboard
|
||||||
* @type {AudioKeys}
|
* @type {AudioKeys}
|
||||||
*/
|
*/
|
||||||
this._keyboard = new AudioKeys({polyphony : 88, rows : 1, octaveControls : false})
|
this._keyboard = new AudioKeys({polyphony : 88, rows : 1, octaveControls : false, rootNote : 48})
|
||||||
this._keyboard.down((e) => {
|
this._keyboard.down((e) => {
|
||||||
this.keyDown(e.note)
|
this.keyDown(e.note)
|
||||||
this._emitKeyDown(e.note)
|
this._emitKeyDown(e.note)
|
||||||
@ -45,7 +45,7 @@ class Keyboard extends events.EventEmitter{
|
|||||||
/**
|
/**
|
||||||
* The piano interface
|
* The piano interface
|
||||||
*/
|
*/
|
||||||
this._keyboardInterface = new KeyboardElement(container, 48, 2)
|
this._keyboardInterface = new KeyboardElement(container, 36, 2)
|
||||||
this._keyboardInterface.on('keyDown', (note) => {
|
this._keyboardInterface.on('keyDown', (note) => {
|
||||||
this.keyDown(note)
|
this.keyDown(note)
|
||||||
this._emitKeyDown(note)
|
this._emitKeyDown(note)
|
||||||
@ -138,7 +138,7 @@ class Keyboard extends events.EventEmitter{
|
|||||||
const keyWidth = 24
|
const keyWidth = 24
|
||||||
let octaves = Math.round((window.innerWidth / keyWidth) / 12)
|
let octaves = Math.round((window.innerWidth / keyWidth) / 12)
|
||||||
octaves = Math.max(octaves, 2)
|
octaves = Math.max(octaves, 2)
|
||||||
this._keyboardInterface.resize(48, octaves)
|
this._keyboardInterface.resize(36, octaves)
|
||||||
}
|
}
|
||||||
|
|
||||||
activate(){
|
activate(){
|
||||||
|
@ -61,7 +61,10 @@ class Roll {
|
|||||||
|
|
||||||
keyDown(midi, box, ai=false){
|
keyDown(midi, box, ai=false){
|
||||||
const selector = ai ? `ai${midi}` : midi
|
const selector = ai ? `ai${midi}` : midi
|
||||||
if (midi && box && !this._currentNotes.hasOwnProperty(selector)){
|
if (!this._currentNotes.hasOwnProperty(selector)){
|
||||||
|
this._currentNotes[selector] = []
|
||||||
|
}
|
||||||
|
if (midi && box){
|
||||||
//translate the box coords to this space
|
//translate the box coords to this space
|
||||||
const initialScaling = 10000
|
const initialScaling = 10000
|
||||||
const plane = new THREE.Mesh( geometry, ai ? aiMaterial : material )
|
const plane = new THREE.Mesh( geometry, ai ? aiMaterial : material )
|
||||||
@ -73,23 +76,26 @@ class Roll {
|
|||||||
plane.position.y = this._element.clientHeight + this._camera.position.y + initialScaling / 2
|
plane.position.y = this._element.clientHeight + this._camera.position.y + initialScaling / 2
|
||||||
this._scene.add(plane)
|
this._scene.add(plane)
|
||||||
|
|
||||||
this._currentNotes[selector] = {
|
this._currentNotes[selector].push({
|
||||||
plane : plane,
|
plane : plane,
|
||||||
position: this._camera.position.y
|
position: this._camera.position.y
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
keyUp(midi, ai=false){
|
keyUp(midi, ai=false){
|
||||||
const selector = ai ? `ai${midi}` : midi
|
const selector = ai ? `ai${midi}` : midi
|
||||||
if (this._currentNotes[selector]){
|
if (this._currentNotes[selector] && this._currentNotes[selector].length){
|
||||||
const plane = this._currentNotes[selector].plane
|
const note = this._currentNotes[selector].shift()
|
||||||
const position = this._currentNotes[selector].position
|
const plane = note.plane
|
||||||
delete this._currentNotes[selector]
|
const position = note.position
|
||||||
// get the distance covered
|
// get the distance covered
|
||||||
plane.scale.y = Math.max(this._camera.position.y - position, 5)
|
plane.scale.y = Math.max(this._camera.position.y - position, 5)
|
||||||
plane.position.y = this._element.clientHeight + position + plane.scale.y / 2
|
plane.position.y = this._element.clientHeight + position + plane.scale.y / 2
|
||||||
|
} else {
|
||||||
|
// console.log(midi)
|
||||||
|
// setTimeout(() => this.keyUp(midi, ai), 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user