| 1 |
// Sample for note on ecxeption mode |
|---|
| 2 |
package { |
|---|
| 3 |
import flash.display.Sprite; |
|---|
| 4 |
import flash.text.TextField; |
|---|
| 5 |
import flash.events.*; |
|---|
| 6 |
import org.si.sion.*; |
|---|
| 7 |
import org.si.sion.utils.SiONPresetVoice; |
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
public class NoteOnException extends Sprite { |
|---|
| 11 |
// driver |
|---|
| 12 |
public var driver:SiONDriver = new SiONDriver(); |
|---|
| 13 |
|
|---|
| 14 |
// voice for sampler "%5,5" |
|---|
| 15 |
public var squareWave:SiONVoice = new SiONVoice(5,5); |
|---|
| 16 |
|
|---|
| 17 |
// note on exception mode |
|---|
| 18 |
public var exceptionMode:Array = [{name:"ignore", mode:SiONDriver.NEM_IGNORE}, |
|---|
| 19 |
{name:"reject", mode:SiONDriver.NEM_REJECT}, |
|---|
| 20 |
{name:"overwrite", mode:SiONDriver.NEM_OVERWRITE}, |
|---|
| 21 |
{name:"shift", mode:SiONDriver.NEM_SHIFT}]; |
|---|
| 22 |
|
|---|
| 23 |
// index |
|---|
| 24 |
public var exceptionModeIndex:int; |
|---|
| 25 |
|
|---|
| 26 |
// text field |
|---|
| 27 |
public var tf:TextField = new TextField(); |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
// constructor |
|---|
| 31 |
function NoteOnException() { |
|---|
| 32 |
// display text |
|---|
| 33 |
addChild(tf); |
|---|
| 34 |
|
|---|
| 35 |
// initialize index |
|---|
| 36 |
exceptionModeIndex = 3; |
|---|
| 37 |
|
|---|
| 38 |
// listen click |
|---|
| 39 |
stage.addEventListener("click", _onClick); |
|---|
| 40 |
|
|---|
| 41 |
// play without data. This only starts streaming. |
|---|
| 42 |
driver.play(); |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
private function _onClick(e:Event) : void |
|---|
| 47 |
{ |
|---|
| 48 |
_changeExceptionMode(); |
|---|
| 49 |
// note on at same time, same trackID = 0 |
|---|
| 50 |
driver.noteOn(60, squareWave, 4, 0, 1, 0); // o5c |
|---|
| 51 |
driver.noteOn(64, squareWave, 4, 0, 1, 0); // o5e |
|---|
| 52 |
driver.noteOn(67, squareWave, 4, 0, 1, 0); // o5g |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
private function _changeExceptionMode() : void |
|---|
| 56 |
{ |
|---|
| 57 |
if (++exceptionModeIndex >= exceptionMode.length) exceptionModeIndex = 0; |
|---|
| 58 |
tf.htmlText = "<font color='#808080'>" + exceptionMode[exceptionModeIndex].name + "</font>"; |
|---|
| 59 |
|
|---|
| 60 |
// set note on exception mode |
|---|
| 61 |
driver.noteOnExceptionMode = exceptionMode[exceptionModeIndex].mode; |
|---|
| 62 |
} |
|---|
| 63 |
} |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|