<html lang="en">
<head>
<meta charset="UTF-8">
<title>DrumsRNN</title>
<script src="https://cdn.jsdelivr.net/npm/@magenta/music@1.14.0"></script>
<script src="https://unpkg.com/@tonejs/midi"></script>
</head>
<body>
Placeholder
</body>
<script>
let generated_seq;
let note_seq
let drums_rnn = new mm.MusicRNN('https://storage.googleapis.com/magentadata/js/checkpoints/music_rnn/drum_kit_rnn');
let byteArray_rnn;
let backToMIDI_rnn
let backToNoteSeq_rnn;
let byteArray_bitmidi;
let backToMIDI_bitmidi;
let backToNoteSeq_bitmidi;
drums_rnn.initialize()
.then(function(){
mm.urlToNoteSequence('https://bitmidi.com/uploads/48860.mid') // Small rhythm midi file
.then(function(url_note_seq){
note_seq = url_note_seq;
quantized_seq = mm.sequences.quantizeNoteSequence(note_seq, 4);
drums_rnn.continueSequence(quantized_seq, 8, 1.4)
.then(function(sample) {
generated_seq = sample;
generated_seq.tempos[0].time = 0;
const unquant_sample = mm.sequences.unquantizeSequence(generated_seq);
console.log('real', note_seq);
console.log('sample', unquant_sample);
byteArray_rnn = mm.sequenceProtoToMidi(unquant_sample);
backToNoteSeq_rnn= mm.midiToSequenceProto(byteArray_rnn); // This note sequence is empty
debugger
backToMIDI_rnn = new Midi(byteArray_rnn) // The MIDI file has one track, but the notes are missing
console.log(backToNoteSeq_rnn);
// Same steps performed with a note_sequence created from a bitmidi file, is able to be converted back and forth
byteArray_bitmidi = mm.sequenceProtoToMidi(note_seq);
backToMIDI_bitmidi = new Midi(byteArray_bitmidi)
backToNoteSeq_bitmidi = mm.midiToSequenceProto(byteArray_bitmidi);
console.log(backToNoteSeq_bitmidi);
});
})
});
</script>
</html>
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |