cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <html>
  <head>
    <script src="https://cdn.jsdelivr.net/npm/@magenta/music@1.0.0"> </script>
    <link href='https://fonts.googleapis.com/css?family=Codystar' rel='stylesheet'>
  </head>

  <body>
    <div class='content' id='wait'>Put on headphones. We'll wait.</div>
    <div class='content' id='start' onclick="start()">CLICK TO TRIO ENDLESSLY.</div>
    <div class='content' id='playing'>
      <marquee scrollamount=15>ENDLESS TRIOS</marquee>
      <marquee scrollamount=15 direction=right >ENDLESS TRIOS</marquee>
      <div class='button' id='next' onclick="sampleAndPlayForever()">Next Trios</div> 
      <marquee behavior=alternate id='count' direction=right>0 TRIOS</marquee>
      <div class='button' onclick="stop()">END TRIOS</div>
      <marquee scrollamount=15>ENDLESS TRIOS</marquee>
      <marquee scrollamount=15 direction=right>ENDLESS TRIOS</marquee>
      <div class='button' onclick="changeTempo(1)">Faster Trios</div>
      <marquee behavior=alternate id='tempo'>bpm</marquee>
      <div class='button' onclick="changeTempo(-1)">Slower Trios</div>
      <marquee scrollamount=15>ENDLESS TRIOS</marquee>
      <marquee scrollamount=15 direction=right>ENDLESS TRIOS</marquee>
    </div>
  </body>
  <footer class='footer'>
    Plays back real-time generated 3-part (melody, bass, drums) from a miniaturized <a href="https://g.co/magenta/musicvae" target="_blank">MusicVAE</a> model. Listen to samples from the full model on <a href="https://www.youtube.com/watch?v=xU1W3c9p2RU&list=PLBUMAYA6kvGVds2N7HIMQnZc0SMFk99Yl" target="_blank">YouTube</a> or sample your own in <a href="https://goo.gl/magenta/musicvae-colab" target="_blank">Colab</a>.
  </footer>
</html>

            
          
!
            
              body {
  background-color:black;
  color:white;
}
.content {
  min-height: 100vh;
  font-family: 'Codystar';
  font-size: 28px;
}
.footer {
  font-family: 'Poppins', Arial, sans-serif;
  font-size: 15px;
  height: 25px;
}

#start, marquee.button, div.button {
  cursor: pointer;
}

#start:hover, div.button:hover, marquee.button:hover {
    color: magenta
}

div.button {
  text-align: center;
}

marquee, div.button {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
            
          
!
            
              // Instantiate the model by specifying the desired checkpoint.
const model = new mm.MusicVAE(
  'https://storage.googleapis.com/magentadata/js/checkpoints/music_vae/trio_4bar');

const player = new mm.Player();

let stopSignal = false;
let count = 0;
let tempo = 80;

const sampleAndPlayForever = () => {
  player.stop();
  count += 1;
  document.getElementById('count').innerHTML = `${count} trios`;
  return model.sample(1)
    .then((samples) => player.start(samples[0], tempo))
    .then(stopSignal ? undefined : sampleAndPlayForever)
};

const changeTempo = (delta) => {
  tempo = Math.max(Math.min(tempo + delta * 10, 120), 40);
  const tempoCounter = document.getElementById('tempo');
  tempoCounter.setAttribute('scrollamount', tempo / 10);
  tempoCounter.innerHTML = `${tempo} bpm`;
}

const start = () =>  {
  mm.Player.tone.context.resume();  // Required on mobile.
  document.getElementById('start').style.display = "none";
  changeTempo(0);
  stopSignal = false;
  sampleAndPlayForever();
};

const stop = () => {
  stopSignal = true;
  player.stop();
  document.getElementById('wait').style.display = "none";
  document.getElementById('start').style.display = "block";
};

model.initialize().then(stop);
            
          
!
999px
Loading ..................

Console