Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<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

Dismiss x
public
Bin info
notwaldorfpro
0viewers