Skip to content

Instantly share code, notes, and snippets.

@NickDimmock
Last active April 2, 2024 06:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickDimmock/3e8dd44a8e777129d332 to your computer and use it in GitHub Desktop.
Save NickDimmock/3e8dd44a8e777129d332 to your computer and use it in GitHub Desktop.
A tool to help with sample slice calculation for the Analog Rytm drum machine.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Analog Rytm: sample slice calculator</title>
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<style>
body {
font-family: 'Roboto', Helvetica, Arial, sans-serif;
font-size: 1.2em;
text-align: center;
}
h1 {
color: #008FB2;
}
h1 span {
color: #FF7B00;
}
p a {
color: #008FB2;
text-decoration: none;
font-weight: bold;
}
p a:hover {
color: #FF7B00;
text-decoration: underline;
}
#tableContainer {
display: none;
width: 650px;
margin-left: auto;
margin-right: auto;
}
#sliceTable {
width: 650px;
border-collapse: collapse;
margin-top: 1em;
margin-left: auto;
margin-right: auto;
font-size: 120%;
}
#sliceTable thead {
font-weight: bold;
}
#sliceTable thead td {
border: 0px;
}
#sliceTable td {
border: 1px solid #444;
text-align: center;
padding: .5em;
}
#sliceTable tr.even {
background: #f8f8f8;
}
#sliceTable td.start {
color: #1ba300
}
#sliceTable td.end {
color: #f44242;
}
#slicePicker {
font-size: 24px;
color: #333;
}
#slicePicker a {
color: #666;
text-decoration: none;
padding: 0 6px;
margin: 0 2px;
border: 2px solid transparent;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
#slicePicker a:hover {
color: #FF7B00;
border: 2px solid #FF7B00;
}
#slicePicker a.selected {
background: #FF7B00;
color: #fff;
border: 2px solid #FF7B00;
}
#intro {
color: #666;
font-size: 120%;
}
.mono {
color: #000 !important;
}
#controls {
text-align: right;
padding-top: 8px;
}
#controls a {
text-decoration: none;
}
#controls a:hover {
text-decoration: underline;
}
a#colour {
color: #FF7B00;
}
a#mono {
color: #000;
}
</style>
</head>
<body>
<h1><span>Analog Rytm</span> sample slice calculator</h1>
<p>Calculate the start and end points for <a href="https://www.elektron.se/products/analog-rytm-mkii/">Rytm</a> sample chain slices.</p>
<div id="slicePicker">Slices: <a href="#" data-slices="2">2</a><a href="#" data-slices="3">3</a><a href="#" data-slices="4">4</a><a href="#" data-slices="5">5</a><a href="#" data-slices="6">6</a><a href="#" data-slices="8">8</a><a href="#" data-slices="10">10</a><a href="#" data-slices="12">12</a><a href="#" data-slices="15">15</a><a href="#" data-slices="20">20</a><a href="#" data-slices="24">24</a><a href="#" data-slices="30">30</a><a href="#" data-slices="40">40</a><a href="#" data-slices="60">60</a><a href="#" data-slices="120" title="Seriously?">120</a></div>
<p id="sliceInfo"></p>
<div id="intro">▲ Pick a slice count to get started.</div>
<div id="tableContainer">
<table id="sliceTable"><thead><tr><td>Slice #</td><td class="start">Start ▶</td><td class="end">◀ End</td></tr></thead><tbody></tbody></table>
<div id="controls"><a href="#" id="colour">colour</a> | <a href='#' id="mono">mono</a></div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script>
$(function() {
var sliceCount;
var slices;
var sliceNumber;
var sliceEnd;
var trClass;
var mono = false;
var onetwenty=['Great Scott!', 'Good grief!', 'Yikes!', 'Oh my.', 'Whoa!', 'Wow.', 'Blimey!', 'Eep!', 'Snakes alive!', 'Good heavens!', 'Bad news!', 'Guess what?', 'Alert!', 'Look alive!', '¡Ay, caramba!', 'Leapin\' lizards!', 'Holy cow!', 'What the...?', 'What on Earth?'];
$('#slicePicker a').click(function(){
event.preventDefault();
$('#slicePicker a').removeClass('selected');
$(this).addClass('selected');
$('#intro').remove();
$('#sliceTable tbody').empty();
sliceCount = parseInt($(this).data('slices'));
slices = 120 / sliceCount;
sliceNumber=1;
trClass='even';
$('#sliceInfo').html('For <strong>' + sliceCount + '</strong> slices you need to advance in increments of <strong>' + slices + '</strong>:');
if(sliceCount == 120) {
$('#sliceInfo').prepend('<em>' + onetwenty[Math.floor(Math.random() * onetwenty.length)] + '</em> ');
}
for(var x=0; x < 120; x+=slices) {
sliceEnd = x + slices;
$('#sliceTable tbody').append('<tr class="' + trClass + '"><td class="sliceResult">' + sliceNumber + '</td><td class="start">' + x + '</td><td class="end">'+sliceEnd + '</td></tr>');
sliceNumber += 1;
trClass == 'even' ? trClass = 'odd' : trClass = 'even';
}
if(mono) {
$('td').addClass('mono');
}
$('#tableContainer').show();
});
$('#mono').click(function(){
event.preventDefault();
mono = true;
$('td').addClass('mono');
});
$('#colour').click(function(){
event.preventDefault();
mono = false;
$('td').removeClass('mono');
});
});
</script>
</body>
</html>
@NickDimmock
Copy link
Author

NickDimmock commented Oct 15, 2017

bl.ocks shortlink: https://bit.ly/rytmcalc.

@NickDimmock
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment