Skip to content

Commit

Permalink
Fixed play behaviour. Added status label.
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiano-belloni committed Sep 27, 2011
1 parent c639431 commit 2addc5c
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 14 deletions.
Binary file added EHSMB.TTF
Binary file not shown.
2 changes: 2 additions & 0 deletions index.html
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<link rel=StyleSheet href="morningstar.css" type="text/css" media=screen>
<title>Morning Star Synth</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="http://github.com/notmasteryet/audiodata/raw/master/audiodata.js"></script>
Expand All @@ -10,6 +11,7 @@
<script type="text/javascript" src="../KievII/graphic_elements/Background.js"></script>
<script type="text/javascript" src="../KievII/graphic_elements/Button.js"></script>
<script type="text/javascript" src="../KievII/graphic_elements/RotKnob.js"></script>
<script type="text/javascript" src="../KievII/graphic_elements/Label.js"></script>
<script type="text/javascript" src="../KievII/graphic_elements/wrappers/CanvasDraw.js"></script>
<script type="text/javascript" src="../KievII/graphic_elements/wrappers/Wrappers.js"></script>
<script type="text/javascript" src="audio/ndprocess.js"></script>
Expand Down
26 changes: 26 additions & 0 deletions morningstar.css
@@ -0,0 +1,26 @@
/*
Document : morningstar
Created on : 27-set-2011, 23.50.06
Author : janesconference
Description:
Purpose of the stylesheet follows.
*/

/*
TODO customize this sample style
Syntax recommendation http://www.w3.org/TR/REC-CSS2/
*/

@font-face {
font-family: "embedded_font";
src: url(EHSMB.TTF);
font-size: 19px;
}
.embed {
font-family: "embedded_font";
}

.embed_msg {
font-family: "embedded_font";
font-size: 19px;
}
83 changes: 69 additions & 14 deletions morningstar.js
Expand Up @@ -22,7 +22,8 @@ var MORNINGSTAR = {
redLeds : [],
currentStep : 0,
currentHLStep : 0,
audioOk : false
audioOk : false,
currentPlayPattern: 0
};

MORNINGSTAR.logError = function (status) {
Expand Down Expand Up @@ -53,22 +54,48 @@ var MORNINGSTAR = {

if ((state === true) && (this.sequenceStep !== -1)) {
// Set the last play key as invisible
this.ui.setVisible(this.playKeys[this.sequenceStep].ID, false);
this.ui.setVisible(this.playKeys[this.sequenceStep % this.STEPS_PER_PATTERN].ID, false);
// Set the last real key as visible
this.ui.setVisible(this.keys[this.sequenceStep].ID, true);
this.ui.setVisible(this.keys[this.sequenceStep % this.STEPS_PER_PATTERN].ID, true);
// Play and stop reset the position; don't do this if you wanna simply pause the sequencer
// Reset the current sequence step
this.sequenceStep = -1;
}
}


MORNINGSTAR.sequencerRoutine = function () {

var step = this.sequenceStep;
// TODO this will be "length" no more.
var nextStep = (step + 1) % this.keys.length;
var changePattern = false;
var nextStep = (this.sequenceStep + 1) % (this.STEPS_PER_PATTERN * this.status.numberOfPatterns);
// Graphical step, the actual key to light.
var nextGrStep = nextStep % this.STEPS_PER_PATTERN;

if ((nextGrStep === 0) /*&& (nextGrStep !== nextStep)*/) {
//Time to change pattern
changePattern = true;
//Last play key becomes invisible
this.ui.setVisible(this.playKeys[this.STEPS_PER_PATTERN - 1].ID, false);
//Last I/O key becomes visible
this.ui.setVisible(this.keys[this.STEPS_PER_PATTERN - 1].ID, true);
//and unclickable, again
this.ui.setClickable(this.keys[this.STEPS_PER_PATTERN - 1].ID, false);
//Actually change pattern
this.switchPattern (nextStep / this.STEPS_PER_PATTERN);
//See if we need to refresh the play LED
if ((nextStep / this.STEPS_PER_PATTERN) !== this.currentPlayPattern) {
//Light the right green led
this.ui.setValue("greenled_" + (nextStep / this.STEPS_PER_PATTERN), 'buttonvalue', 1);
// Turn the previous green led off
this.ui.setValue("greenled_" + this.currentPlayPattern, 'buttonvalue', 0);
}
// Update the current play pattern
this.currentPlayPattern = nextStep / this.STEPS_PER_PATTERN;

}

// Play note
// TODO this will become "active"
if (this.keys[nextStep].getValue("buttonvalue") === 1) {
if (this.status.steps[nextStep].active === 1) {
if (this.audioOk === true) {
// If the next step is active, turn the playing note off.
this.ADNonDescript.noteOff();
Expand All @@ -80,20 +107,21 @@ var MORNINGSTAR = {

}

if (this.sequenceStep !== -1) {
// If we're not at the first step
if (nextGrStep !== 0) {
//Restore previous key
//play key becomes invisible
this.ui.setVisible(this.playKeys[step].ID, false);
this.ui.setVisible(this.playKeys[nextGrStep - 1].ID, false);
//i/o key becomes visible
this.ui.setVisible(this.keys[step].ID, true);
this.ui.setVisible(this.keys[nextGrStep - 1].ID, true);
//and unclickable, again
this.ui.setClickable(this.keys[step].ID, false);
this.ui.setClickable(this.keys[nextGrStep - 1].ID, false);
}

//i/o key is invisible
this.ui.setVisible(this.keys[nextStep].ID, false);
this.ui.setVisible(this.keys[nextGrStep].ID, false);
//play key becomes visible
this.ui.setVisible(this.playKeys[nextStep].ID, true);
this.ui.setVisible(this.playKeys[nextGrStep].ID, true);
//increment position
this.sequenceStep = nextStep;
// This could be conditional, if refresh() takes too much time.
Expand Down Expand Up @@ -309,6 +337,8 @@ var MORNINGSTAR = {

this.switchPattern(ledToGo);

this.ui.setValue("statusLabel", 'labelvalue', "Edit pattern: " + (parseInt(ledToGo,10)+ 1));

this.ui.refresh();
}

Expand All @@ -329,6 +359,8 @@ var MORNINGSTAR = {

this.switchPattern(ledToGo);

this.ui.setValue("statusLabel", 'labelvalue', "Edit pattern: " + (parseInt(ledToGo,10)+ 1));

this.ui.refresh();
}

Expand Down Expand Up @@ -374,6 +406,8 @@ var MORNINGSTAR = {
this.switchPattern(this.status.currentEditPattern);
}

this.ui.setValue("statusLabel", 'labelvalue', "N. of patterns: " + this.status.numberOfPatterns);

this.ui.refresh();
}

Expand All @@ -385,6 +419,7 @@ var MORNINGSTAR = {
console.log ("Calling ADNonDescript[" + functionName + "] with value " + value + "-->" + interpolated_value);
this.ADNonDescript[functionName](interpolated_value);
}
this.ui.setValue("statusLabel", 'labelvalue', ID + ": " + interpolated_value);
this.ui.refresh();
};

Expand All @@ -395,6 +430,7 @@ var MORNINGSTAR = {
// a = 0, b = 1, z = 180, y = 60
this.tempo_value = Math.round(value * 120 + 60);
console.log ("TEMPO set to ", this.tempo_value);
this.ui.setValue("statusLabel", 'labelvalue', "BPM: " + this.tempo_value);
}
this.ui.refresh();
};
Expand All @@ -404,6 +440,25 @@ var MORNINGSTAR = {
var key_initial_offset = 67 - 43,
key_distance = 55;

/* LABEL INIT */

// Every element calls label's setValue in the callback, so let's make sure
// that label is declared first.
this.label = new Label({
ID: 'statusLabel',
width : 320,
height : 29,
top : 69,
left : 42,
objParms: {
font: "28px embedded_font",
textColor: "#000",
textBaseline: "top",
textAlignment: "left"
}
});
this.ui.addElement(this.label, {zIndex: 3});

/* BACKGROUND */

var backgroundArgs = {
Expand Down

0 comments on commit 2addc5c

Please sign in to comment.