LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

step

Copy & save this code to come back to your song later.

It should look something like:
[;24:1 ;37:1 ;80:1 ;84:1 ;7:1 ;3:1 ;15]

CSS
html {
  min-height: 100%;
  font-family: Poppins, Helvetica, Arial, sans-serif;
  background: #EB3349;
  background: -webkit-linear-gradient(top left, #EB3349, #F45C43);
  background: linear-gradient(to bottom right, #EB3349, #F45C43);
}

body {
  height: 100%;
  margin: 0;
  font-size: 16px;
}

body.no-overflow {
  overflow: hidden;
}

#aligner {
  height: 100%;
  min-height: 99vh;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
}

#aligner * {
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

h1 {
  font-weight: 600;
  padding: 0;
  margin: 0;
  color: #F36E6B;
  letter-spacing: 10px;
}

#board {
  margin: 10px 0 0 0;
  position: relative;
  -webkit-box-flex: 0;
      -ms-flex: none;
          flex: none;
  width: 480px;
  font-size: 0;
  background-color: transparent;
  cursor: crosshair;
  overflow: hidden;
}

.holder {
  display: inline-block;
  height: 24px;
  width: 24px;
  margin: 3px;
  border-radius: 2px;
  background-color: #F36E6B;
}

.forward .holder {
  -webkit-animation: line 3s linear infinite;
          animation: line 3s linear infinite;
}
.forward .holder:nth-child(16n + 0) {
  -webkit-animation-delay: 0s;
          animation-delay: 0s;
}
.forward .holder:nth-child(16n + 1) {
  -webkit-animation-delay: 0.1875s;
          animation-delay: 0.1875s;
}
.forward .holder:nth-child(16n + 2) {
  -webkit-animation-delay: 0.375s;
          animation-delay: 0.375s;
}
.forward .holder:nth-child(16n + 3) {
  -webkit-animation-delay: 0.5625s;
          animation-delay: 0.5625s;
}
.forward .holder:nth-child(16n + 4) {
  -webkit-animation-delay: 0.75s;
          animation-delay: 0.75s;
}
.forward .holder:nth-child(16n + 5) {
  -webkit-animation-delay: 0.9375s;
          animation-delay: 0.9375s;
}
.forward .holder:nth-child(16n + 6) {
  -webkit-animation-delay: 1.125s;
          animation-delay: 1.125s;
}
.forward .holder:nth-child(16n + 7) {
  -webkit-animation-delay: 1.3125s;
          animation-delay: 1.3125s;
}
.forward .holder:nth-child(16n + 8) {
  -webkit-animation-delay: 1.5s;
          animation-delay: 1.5s;
}
.forward .holder:nth-child(16n + 9) {
  -webkit-animation-delay: 1.6875s;
          animation-delay: 1.6875s;
}
.forward .holder:nth-child(16n + 10) {
  -webkit-animation-delay: 1.875s;
          animation-delay: 1.875s;
}
.forward .holder:nth-child(16n + 11) {
  -webkit-animation-delay: 2.0625s;
          animation-delay: 2.0625s;
}
.forward .holder:nth-child(16n + 12) {
  -webkit-animation-delay: 2.25s;
          animation-delay: 2.25s;
}
.forward .holder:nth-child(16n + 13) {
  -webkit-animation-delay: 2.4375s;
          animation-delay: 2.4375s;
}
.forward .holder:nth-child(16n + 14) {
  -webkit-animation-delay: 2.625s;
          animation-delay: 2.625s;
}
.forward .holder:nth-child(16n + 15) {
  -webkit-animation-delay: 2.8125s;
          animation-delay: 2.8125s;
}
.forward .holder:nth-child(16n + 16) {
  -webkit-animation-delay: 3s;
          animation-delay: 3s;
}

.loading .holder {
  -webkit-animation: pulse 3s infinite;
          animation: pulse 3s infinite;
}

.note {
  background-color: transparent;
  border-radius: 2px;
  width: 100%;
  height: 100%;
  -webkit-transition: all 0.1s;
  transition: all 0.1s;
}

.note.active {
  background-color: #FFF;
  box-shadow: 0 0 5px #FFF;
}

#file-controls {
  position: fixed;
  background: rgba(255, 255, 255, 0.1);
  top: 0;
  right: 0;
}

.button {
  display: inline-block;
  background-color: #F36E6B;
  width: 50px;
  height: 50px;
  border-radius: 2px;
  text-align: center;
  margin: 10px;
  cursor: crosshair;
  vertical-align: bottom;
  -webkit-transition: 0.1s all;
  transition: 0.1s all;
}
.button svg {
  fill: rgba(255, 255, 255, 0.5);
  width: 20px;
  height: 20px;
  -webkit-transform: translateY(15px);
          transform: translateY(15px);
}
.button:hover {
  background-color: #FCD7D6;
}
.button:active {
  height: 45px;
}
.button:hover > svg {
  fill: #F45C43;
}

.alt {
  margin: 0;
  padding: 0;
  background: transparent;
}
.alt svg {
  fill: #FCD7D6;
  width: 25px;
  height: 25px;
  opacity: 0.6;
  -webkit-transform: translateY(12px);
          transform: translateY(12px);
}
.alt:hover > svg {
  opacity: 1;
}

#audio rect {
  display: inline-block;
}
#audio.mute rect {
  display: none;
}

.ripple {
  position: absolute;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 100%;
  width: 24px;
  height: 24px;
  z-index: -1;
  opacity: 1;
  -webkit-transform: scale(0);
          transform: scale(0);
}

.huzzar {
  opacity: 0;
  -webkit-transform: scale(8);
          transform: scale(8);
  -webkit-transition: all 0.5s;
  transition: all 0.5s;
}

#markers {
  text-align: center;
  cursor: default;
  margin: 10px 0 0 0;
  position: relative;
  -webkit-box-flex: 0;
      -ms-flex: none;
          flex: none;
  width: 480px;
  font-size: 0;
}
#markers span {
  font-size: 2rem;
  display: inline-block;
  height: 24px;
  width: 24px;
  margin: 3px;
  margin-bottom: 0;
  background-color: none;
  line-height: 8px;
  color: #F36E6B;
}

.ui-dialog {
  z-index: 1001;
  font-size: 1rem;
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.65);
  background: #EB3349;
  box-shadow: 0 50px 100px -25px rgba(0, 0, 0, 0.4), 0 0 200px -50px rgba(255, 255, 255, 0.4);
  padding: 10px;
  border: none;
  outline: none;
}
.ui-dialog textarea {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.9);
  outline: none;
  border: none;
  padding: 2px;
  border-radius: 5px;
  min-height: 150px;
  resize: none;
  cursor: text;
}
.ui-dialog textarea::-moz-selection {
  background: rgba(98, 191, 237, 0.99);
  color: #FFF;
}
.ui-dialog textarea::selection {
  background: rgba(98, 191, 237, 0.99);
  color: #FFF;
}

.ui-dialog-titlebar {
  cursor: move;
  font-size: 1.4rem;
  color: rgba(255, 255, 255, 0.9);
}

.ui-dialog-titlebar-close {
  height: 30px;
  width: 30px;
  line-height: 30px;
  font-size: 30px;
  background: transparent;
  border: none;
  outline: none;
  float: right;
  -webkit-transition: 0.1s all;
  transition: 0.1s all;
}
.ui-dialog-titlebar-close:hover {
  color: #FFF;
}

.ui-dialog-buttonpane {
  padding: 10px 0;
  text-align: center;
}

.ui-dialog-buttonset button {
  border: none;
  outline: none;
  background: rgba(255, 255, 255, 0.8);
  color: #EB3349;
  border-radius: 2px;
}

#ui-widget-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #000;
  opacity: 0;
  z-index: -1;
  -webkit-transition: z-index 0s 0.2s, opacity 0.2s;
  transition: z-index 0s 0.2s, opacity 0.2s;
}

#ui-widget-overlay.visible {
  cursor: default;
  opacity: 0.6;
  z-index: 1000;
  -webkit-transition: z-index 0s, opacity 0.2s;
  transition: z-index 0s, opacity 0.2s;
}

.ui-helper-hidden-accessible {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

#social-container {
  opacity: 0.6;
  bottom: 5px;
  right: 5px;
}

#social-container p {
  padding-bottom: 0;
  margin-bottom: 0;
}

#social-container #social-links a {
  font-size: 2rem;
}

#social-message {
  font-size: 0.8rem;
}

@-webkit-keyframes line {
  0% {
    background: #FCD7D6;
  }
  30% {
    background: #F36E6B;
  }
}

@keyframes line {
  0% {
    background: #FCD7D6;
  }
  30% {
    background: #F36E6B;
  }
}
@-webkit-keyframes pulse {
  40% {
    background: #FCD7D6;
  }
}
@keyframes pulse {
  40% {
    background: #FCD7D6;
  }
}
@media (max-width: 480px) {
  #social-container #social-links, #social-container #tooltip {
    display: none;
  }

  #board {
    width: 352px;
  }

  .holder {
    height: 20px;
    width: 20px;
    margin: 1px;
    border-radius: 0;
  }

  .note {
    border-radius: 0;
  }

  .ripple {
    height: 20px;
    width: 20px;
  }

  #markers {
    width: 352px;
  }
  #markers span {
    height: 20px;
    width: 20px;
    margin: 1px;
  }
}
@media (max-height: 700px) {
  #aligner {
    -webkit-box-pack: start;
        -ms-flex-pack: start;
            justify-content: flex-start;
    padding: 20px;
  }
}
JS
var buttons = 256,
	rows = 16;
var cols = rows;
var wLoaded = false,
	nLoaded = false;

$(document).ready(function() {
	var holder = $('#board .holder'),
		note = $('.note');
	var notes = [];

	for (var i = 0; i < rows; i++) {
		notes[i] = new Howl({
			urls: ['https://s3-us-west-2.amazonaws.com/s.cdpn.io/380275/' + i + '.mp3',
				'https://s3-us-west-2.amazonaws.com/s.cdpn.io/380275/' + i + '.ogg'
			],
			onload: loadCount(i + 1)
		});
	}

	$(window).load(function() {
		bindUserActions();
		initControls();

		wLoaded = true;
		if (nLoaded)
			$('#board').removeClass('loading').addClass('forward');

		for (var i = 0; i < rows; i++) {
			bindNote(i);
		}
	});

	function loadCount(i) {
		if (i === rows) {
			nLoaded = true;
			if (wLoaded)
				$('#board').removeClass('loading').addClass('forward');
		}
	}

	function bindNote(currNote) {
		$('#board .holder:nth-child(' + cols + 'n + ' + currNote + ')')
		.on('webkitAnimationIteration mozAnimationIteration animationiteration', 
		function() {
			if ($(this).hasClass('active')) {
				var currNote = $(this).attr('data-note');
				notes[currNote].play();

				$(this).find('.ripple').addClass('huzzar').delay(500).queue(function() {
					$(this).removeClass('huzzar').dequeue();
				});
			}
		});
	}

	function bindUserActions() {
		$(note).mousedown(function() {
			$(this).toggleClass("active");
			$(this).parent().toggleClass("active");
		});
		$(document).mousedown(function() {
			$(note).bind('mouseover', function() {
				$(this).toggleClass("active");
				$(this).parent().toggleClass("active");
			});
		}).mouseup(function() {
			$(note).unbind('mouseover');
		});
		$("#dialogSave").dialog({
			autoOpen: false,
			modal: true,
			closeText: "✖",
			hide: 200
		});
		$("#dialogLoad").dialog({
			autoOpen: false,
			buttons: [{
				text: "Play",
				click: function() {
					importLoop($(this));
				}
			}],
			modal: true,
			closeText: "✖",
			hide: 200
		});
	}

	function initControls() {
		$('#reset').on('click', function() {
			$('.active').removeClass('active');
		});
		$('#audio').on('click', function() {
			if ($(this).hasClass("mute"))
				Howler.unmute();
			else
				Howler.mute();
			$(this).toggleClass('mute');
		});
		$('#save').on('click', function() {
			if ($(".dialog").dialog("isOpen") !== true)
				exportLoop();
		});
		$('#load').on('click', function() {
			if ($(".dialog").dialog("isOpen") !== true)
				$("#dialogLoad").dialog("open");
		});

		$('.ui-dialog').on('dialogopen', function(event) {
			$('body').addClass('no-overflow');
			Howler.volume(0.5);
			$('#ui-widget-overlay').addClass('visible');
		}).on('dialogclose', function(event) {
			$('body').removeClass('no-overflow');
			Howler.volume(1);
			$('textarea#saveCode').val('');
			$('#ui-widget-overlay').removeClass('visible');
		});
	}

	//:x represents ON //;x represents OFF
	function exportLoop() {
		var noteCode = "",
			offCount = 0,
			onCount = 0;

		holder.each(function() {
			if ($(this).hasClass('active')) {
				if (offCount > 0)
					noteCode = noteCode + ";" + offCount;
				onCount++;
				offCount = 0;
			} else {
				if (onCount > 0)
					noteCode = noteCode + ":" + onCount + " ";
				offCount++;
				onCount = 0;
			}
		});

		if (offCount > 0)
			noteCode = noteCode + ";" + offCount;
		else if (onCount > 0)
			noteCode = noteCode + ":" + onCount;

		$("#saveCode").val("[" + noteCode + "]");
		$("#dialogSave").dialog("open");
	}

	function importLoop(dialog) {
		var noteCode = '',
			 noteState,
			 error = false,
			 note;

		noteCode = dialog.find('textarea#importCode').val();
		dialog.dialog("close");

		noteCode = noteCode.replace("[", "");
		noteCode = noteCode.replace("]", "");

		if (noteCode.charAt(0) === ":")
			noteState = 1;
		else if (noteCode.charAt(0) === ";")
			noteState = 0;
		else {
			alert("Your note code wasn't recognised");
			error = true;
		}

		if (!error) {
			$('.active').removeClass('active');
			noteCode = noteCode.substr(1);
			var splitCode = noteCode.split(/:|;/g);
			var noteCounter = 0;

			for (i = 0; i < splitCode.length; i++) {
				var currNum = parseInt(splitCode[i]);

				if (noteState) {
					for (var n = 0; n < currNum; n++) {
						noteCounter++;
						note = $('#board span:nth-child(' + noteCounter + ')');
						note.addClass('active');
						note.children().addClass('active');
					}
				} else {
					noteCounter = noteCounter + currNum;
				}
				noteState = !noteState;
			}
		}
	}
});

social("codepen/woodwork", "twitter/joeharry__", "light");
Host Instantly Drag and Drop Website Builder

 

Description

A basic step sequencer based on Yamaha's Tenori-On. Click or drag over the squares to make music. You can export and import your creations to save them for later, or if it's verging on Mozart - share it in the comments.
Term
Mon, 11/27/2017 - 21:41

Related Codes

Pen ID
Pen ID
Pen ID