Go on with hacking midi: load all messages for all rooms. So that, we have the full midi partition with the notes for computing the tempo.
This commit is contained in:
parent
e09dd47f4d
commit
bc9350dbb5
|
@ -483,10 +483,7 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
|
|||
break;
|
||||
|
||||
case 'org.matrix.midi':
|
||||
//if (isLiveEvent)
|
||||
{
|
||||
MidiEventHandler.handleEvent(event);
|
||||
}
|
||||
MidiEventHandler.handleEvent(event, isLiveEvent);
|
||||
|
||||
break;
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ angular.module('eventStreamService', [])
|
|||
// Initial sync: get all information and the last 30 messages of all rooms of the user
|
||||
// 30 messages should be enough to display a full page of messages in a room
|
||||
// without requiring to make an additional request
|
||||
matrixService.initialSync(30, false).then(
|
||||
matrixService.initialSync(10000, false).then(
|
||||
function(response) {
|
||||
var rooms = response.data.rooms;
|
||||
for (var i = 0; i < rooms.length; ++i) {
|
||||
|
|
|
@ -28,22 +28,20 @@ var MidiEventHandler = {
|
|||
currentMeasureTime: 0,
|
||||
perLine: -1,
|
||||
|
||||
init: function () {
|
||||
MIDI.loadPlugin({
|
||||
soundfontUrl: "./soundfont/",
|
||||
instrument: "acoustic_grand_piano",
|
||||
callback: function () {
|
||||
/*
|
||||
var delay = 0; // play one note every quarter second
|
||||
var note = 50; // the MIDI note
|
||||
var velocity = 127; // how hard the note hits
|
||||
// play the note
|
||||
MIDI.setVolume(0, 127);
|
||||
MIDI.noteOn(0, note, velocity, delay);
|
||||
MIDI.noteOff(0, note, delay + 0.75);
|
||||
*/
|
||||
pastMidiEventsInWrongOrder: [],
|
||||
|
||||
init: function (eventHandlerService) {
|
||||
|
||||
// During initialSync, handleEvent is called for each event from latest events to the past.
|
||||
// Need to reorder them.
|
||||
var self = this;
|
||||
eventHandlerService.waitForInitialSyncCompletion().then(
|
||||
function() {
|
||||
for (var i = self.pastMidiEventsInWrongOrder.length - 1; i >= 0; i--) {
|
||||
self.handleEvent(self.pastMidiEventsInWrongOrder[i], true);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
|
@ -81,7 +79,12 @@ notes C-D-E/4 #0# =:: C-D-E-F/4 =|=");
|
|||
this.render();
|
||||
},
|
||||
|
||||
handleEvent: function(event) {
|
||||
handleEvent: function(event, isLiveEvent) {
|
||||
|
||||
if(!isLiveEvent) {
|
||||
this.pastMidiEventsInWrongOrder.push(event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 === this.beat)
|
||||
{
|
||||
|
@ -120,8 +123,10 @@ notes C-D-E/4 #0# =:: C-D-E-F/4 =|=");
|
|||
|
||||
var musicFraction;
|
||||
|
||||
// Flag to ignore artefact(???)
|
||||
var trashIt = false;
|
||||
|
||||
var duration = Math.floor(Math.log2(1 / fraction)) - 1;
|
||||
var duration = Math.floor(Math.log2(1 / fraction)) - 1;
|
||||
switch (duration) {
|
||||
case 4:
|
||||
musicFraction = "w";
|
||||
|
@ -141,8 +146,19 @@ notes C-D-E/4 #0# =:: C-D-E-F/4 =|=");
|
|||
case -2:
|
||||
musicFraction = "32";
|
||||
break;
|
||||
|
||||
default :
|
||||
|
||||
console.log("## Ignored note");
|
||||
// Too short, ignore it
|
||||
trashIt = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// Matthew is about to fix it
|
||||
if (trashIt) return;
|
||||
|
||||
this.currentMeasureTime += duration;
|
||||
|
||||
|
||||
|
|
|
@ -650,6 +650,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
|
|||
$scope.onInit = function() {
|
||||
console.log("onInit");
|
||||
|
||||
MidiEventHandler.init(eventHandlerService);
|
||||
MidiEventHandler.reset();
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue