// changed at Mon Feb 09 2015 13:32:12 GMT+0100 (Central Europe Standard Time) by timfelgentr
eff
this.addScript(function reset() {
    this.get("Music").removeAllMorphs();
    this.setParameters();
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Rectangle
Tag:
run
save
Tests

-- ALL --

setParameters
voice1Chords
voice2Chords
Scripts
-
+
-
Connections
+
-- ALL --
all
ObjectEditor -- Rectangle>>reset
X

Menu

this Note13
Filter:
this.note = 'Bb5'
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Bind 'this' to selection
Inspector on: lively.morphic.Morph
X

Menu
// changed at Mon Feb 09 2015 13:31:53 GMT+0100 (Central Europe Standard Time) by timfelgen
treff
this.addScript(function constraints(gaplen) {
    this.reset();
    var noteProto = this.get("Note"),
        music = this.get("Music");
    noteProto.reset();
    bbb.defaultSolver = new BacktalkSolver();
    this.voice1 = Array.range(1, len).map(function(i) {
        var note = noteProto.copy();
        music.addMorph(note);
        note.time = i;
        always: { note.note.is in this.voice1Chords() }
        return note;
    }.bind(this));
    this.voice2 = Array.range(1, len + gap).map(function(i) {
        var note = noteProto.copy();
        if (i <= len) music.addMorph(note);
        note.time = i;
        always: { note.note.is in this.voice2Chords() }
        return note;
    }.bind(this));
    this.voice1.each(function (note1, idx) {
        var note2 = this.voice2[idx],
            note1f = this.voice1[idx + 1],
            note2f = this.voice2[idx + 1],
            note1gap = this.voice1[idx + gap],
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
<lively.morphic.Box#7FC63... - Rectangle>
Tag:
run
save
Tests

-- ALL --

isValidBichord
reset
setParameters
voice1Chords
voice2Chords
Scripts
-
+
-
Connections
+
-- ALL --
all
ObjectEditor -- Rectangle>>constraints
X

Menu
midi_writer.js
X

Menu
N

...
../
pat/
libtimidity.js (not parsed)
midi.js (not parsed)
midi_writer.js
codes2Str (function)
isArray (function)
MetaEvent (function)
MetaEvent.prototype (object)
MidiEvent (function)
MidiEvent.prototype (object)
MidiTrack (function)
MidiTrack.prototype (object)
MidiWriter (function)
str2Bytes (function)
StringToNumArray (function)
translateTickTime (function)
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
 *
 * @param note {Note || String} Note object or string
 * @param time {Number} Duration of the note in ticks
 * @returns MIDI event with type NOTE_ON for the note specified
 */
MidiEvent.noteOn = function(noteduration) {
    return new MidiEvent({
        time:    note.duration || duration || 0,
        type:    EVT_NOTE_ON,
        channel: note.channel || DEFAULT_CHANNEL,
        param1:  note.pitch   || note,
        param2:  note.volume  || DEFAULT_VOLUME
    });
};
/**
 * Returns an event of the type NOTE_OFF taking the values passed and falling
 * back to defaults if they are not specified.
 *
 * @param note {Note || String} Note object or string
 * @param time {Number} Duration of the note in ticks
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
<
Saving ../users/timfelgentreff/midijs/midi_writer.js... Successfully saved Successfully evaluated ../users/timfelgentreff/midijs/midi_writer.js
depth: 1
reset
users.timfelgentreff.midijs.midi.MIDIjs.play("http://www.midijs.net/midi/alan_jackson_dont_rock_the_jukebox.mid")
users.timfelgentreff.midijs.midi.MIDIjs.stop()
users.timfelgentreff.midijs.midi_writer.MidiTrack
String(["/home/tim/Dev/babelsberg-js/LivelyKernel/core/../users/timfelgentreff/z3/z3","-T:4","-smt2","-in"])
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
show vars
JavaScript Workspace
X

Menu

this Note1
Filter:
this.note = 'C5'
this.show()
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Bind 'this' to selection
Inspector on: lively.morphic.Morph
X

Menu
// changed at Mon Feb 09 2015 13:56:02 GMT+0100 (Central Europe Standard Time) by timfelgentr
eff
this.addScript(function doAction() {
    var MidiTrack = Global.users.timfelgentreff.midijs.midi_writer.MidiTrack,
        MidiWriter = Global.users.timfelgentreff.midijs.midi_writer.MidiWriter,
        MidiEvent = Global.users.timfelgentreff.midijs.midi_writer.MidiEvent,
        track1 = new MidiTrack({
            events: [
                MidiEvent.programChange(32)
            ].concat(this.owner.voice1.map(function(note) {
                return MidiEvent.createNote(note.note);
            }).flatten())
        }),
        track2 = new MidiTrack({
            events: [
                MidiEvent.programChange(32)
            ].concat(this.owner.voice2.slice(0, this.owner.numChords).map(function(note) {
                return MidiEvent.createNote(note.note);
            }).flatten())
        });
    var song  = MidiWriter({ tracks: [track1, track2] });
    // song.save()
    Global.users.timfelgentreff.midijs.midi.MIDIjs.playString(atob(song.b64));
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
<lively.morphic.Button#4EB9B... - Button2>
Tag:
run
save
Tests

-- ALL --

Scripts
-
+
-
Connections
+
-- ALL --
fire,AttributeConnection(<lively.morphic.Button#4EB9B... - Button2>.fire --> <lively.morphic.Button#4EB9B... - Button2>.doAction)
all
ObjectEditor -- Button2>>doAction
X

Menu
saved source
30
Length
6
Gap
Make
Play
depth: 1
reset
var MidiTrack = users.timfelgentreff.midijs.midi_writer.MidiTrack;
var MidiWriter = users.timfelgentreff.midijs.midi_writer.MidiWriter
var noteEvents = [];
["Db4", "E4", "G4"].forEach(function(note) {
    Array.prototype.push.apply(
        noteEvents,
        users.timfelgentreff.midijs.midi_writer.MidiEvent.createNote(note));
});
var track = new MidiTrack({ events: noteEvents });
song  = MidiWriter({ tracks: [track] });
song.play
// song.save();
URL.createObjectURL
atob(song.b64)
users.timfelgentreff.midijs.midi.MIDIjs.playString(atob(song.b64))
new DataView(song.b64)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
show vars
JavaScript Workspace
X

Menu