|
MID ÇÁ·ÎÇÊ | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ToneControl
Àº »ç¿ëÀÚ Á¤ÀÇ ¸ð³ë Åæ ½ÃÄö½º¸¦
Àç»ýÇÒ ¼ö ÀÖ´Â ÀÎÅÍÆäÀ̽ºÀÔ´Ï´Ù.
Åæ ½ÃÄö½º´Â Åæ Àç»ý ½Ã°£ ½Ö ¸ñ·Ï°ú »ç¿ëÀÚ Á¤ÀÇ
½ÃÄö½º ºí·ÏÀ¸·Î ÁöÁ¤µË´Ï´Ù.
¸ñ·ÏÀº ¹ÙÀÌÆ®ÀÇ ¹è¿·Î ÆÐŰÁöȵ˴ϴÙ.
setSequence
¸Þ¼Òµå´Â ToneControl
¿¡ ½ÃÄö½º¸¦ ÀÔ·ÂÇÏ´Â µ¥ »ç¿ëµË´Ï´Ù.
Åæ ½ÃÄö½º ±¸¹®Àº Augmented BNF ÁÖ¼®¿¡ ¼³¸íµÇ¾î ÀÖ½À´Ï´Ù.
sequence = version *1tempo_definition *1resolution_definition *block_definition 1*sequence_event version = VERSION version_number VERSION = byte-value version_number = 1 ; version # 1 tempo_definition = TEMPO tempo_modifier TEMPO = byte-value tempo_modifier = byte-value ; multiply by 4 to get the tempo (in bpm) used ; in the sequence. resolution_definition = RESOLUTION resolution_unit RESOLUTION = byte-value resolution_unit = byte-value block_definition = BLOCK_START block_number 1*sequence_event BLOCK_END block_number BLOCK_START = byte-value BLOCK_END = byte-value block_number = byte-value ; block_number specified in BLOCK_END has to be the ; same as the one in BLOCK_START sequence_event = tone_event / block_event / volume_event / repeat_event tone_event = note duration note = byte-value ; note to be played duration = byte-value ; duration of the note block_event = PLAY_BLOCK block_number PLAY_BLOCK = byte-value block_number = byte-value ; block_number must be previously defined ; by a full block_definition volume_event = SET_VOLUME volume SET_VOLUME = byte-value volume = byte-value ; new volume repeat_event = REPEAT multiplier tone_event REPEAT = byte-value multiplier = byte-value ; number of times to repeat a tone byte-value = -128 - 127 ; the value of each constant and additional ; constraints on each parameter are specified below.
VERSION
,
TEMPO
,
RESOLUTION
,
BLOCK_START
,
BLOCK_END
,
PLAY_BLOCK
SET_VOLUME
REPEAT
´Â
¹Ì¸® Á¤ÀÇµÈ »ó¼öÀÔ´Ï´Ù.
´ÙÀ½ Å×À̺íÀº À¯È¿ÇÑ ¸Å°³ º¯¼ö ¹üÀ§¸¦ º¸¿© ÁÝ´Ï´Ù.
À½Ç¥ÀÇ Á֯ļö´Â ´ÙÀ½ °ø½ÄÀ¸·Î °è»êÇÒ ¼ö ÀÖ½À´Ï´Ù.
¸Å°³ º¯¼ö ¿Ã¹Ù¸¥ ¹üÀ§ À¯È¿ ¹üÀ§ ±âº»°ª tempo_modifier
5<= tempo_modifier
<= 12720bpm - 508bpm 120bpm resolution_unit
1<= resolution_unit
<= 1271/1 À½Ç¥ - 1/127 À½Ç¥ 1/64 À½Ç¥ block_number
0<= block_number
<= 127- - note
0<= note
<= 127 ¶Ç´Â SILENCEC-1 - G9 ¶Ç´Â ³ª¸ÓÁö - duration
1<= duration
<= 127- - volume
0<= volume
<= 1000% - 100% º¼·ý 100% multiplier
2<= multiplier
<= 127- -
SEMITONE_CONST = 17.31234049066755 = 1/(ln(2^(1/12))) note = ln(freq/8.176)*SEMITONE_CONSTÀ½Ç¥ A = À½Ç¥ 69(0x45) = 440Hz.
°¢ ÅæÀÇ Àç»ý ½Ã°£Àº 1/À½Àý ºÐ¿ ´ÜÀ§·Î ÃøÁ¤µÇ¸ç
ÅÛÆ÷´Â ºñÆ®/ºÐÀ¸·Î ÁöÁ¤µË´Ï´Ù. ¿©±â¼ 1ºñÆ® = 1/4À½Ç¥ÀÔ´Ï´Ù.
byte
ÀÇ ¾ç¼ö °ª ¹üÀ§´Â 1 - 127À̹ǷΠÅÛÆ÷´Â
ÅÛÆ÷ ¼öÁ¤ÀÚ¿¡ 4¸¦ °öÇÏ¿© Çü¼ºµË´Ï´Ù.
¾ÆÁÖ ´À¸° ÅÛÆ÷´Â Á¦¿ÜµÇ¹Ç·Î
ÅÛÆ÷ ¼öÁ¤ÀÚÀÇ ¹üÀ§°¡ 5 - 127À̾î¼
20 - 508bpmÀÇ À¯È¿ ¹üÀ§¸¦ Á¦°øÇÕ´Ï´Ù.
ÅæÀÇ À¯È¿ Àç»ý ½Ã°£À» ¹Ð¸®ÃÊ ´ÜÀ§·Î °è»êÇϱâ À§ÇØ ´ÙÀ½ °ø½ÄÀ» »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.
duration * 60 * 1000 * 4 / (resolution * tempo)´ÙÀ½ Å×À̺íÀº À½Ç¥¿¡¼ »ç¿ëµÇ´Â ¸î¸î ÀϹÝÀûÀÎ Àç»ý ½Ã°£À» ³ª¿ÇÕ´Ï´Ù.
À½Ç¥ ±æÀÌ Àç»ý ½Ã°£, À½Àý ºÐ¿=64 Àç»ý ½Ã°£, À½Àý ºÐ¿=96 1/1 64 96 1/4 16 24 1/4 Á¡À½Ç¥ 24 36 1/8 8 12 1/8 3¿¬À½Ç¥ - 8 4/1 REPEAT
4 <À½Ç¥> 64REPEAT
4 <À½Ç¥> 96
// "Mary Had A Little Lamb" has "ABAC" structure. // Use block to repeat "A" section. byte tempo = 30; // set tempo to 120 bpm byte d = 8; // eighth-note byte C4 = ToneControl.C4;; byte D4 = (byte)(C4 + 2); // a whole step byte E4 = (byte)(C4 + 4); // a major third byte G4 = (byte)(C4 + 7); // a fifth byte rest = ToneControl.SILENCE; // rest byte[] mySequence = { ToneControl.VERSION, 1, // version 1 ToneControl.TEMPO, tempo, // set tempo ToneControl.BLOCK_START, 0, // start define "A" section E4,d, D4,d, C4,d, E4,d, // content of "A" section E4,d, E4,d, E4,d, rest,d, ToneControl.BLOCK_END, 0, // end define "A" section ToneControl.PLAY_BLOCK, 0, // play "A" section D4,d, D4,d, D4,d, rest,d, // play "B" section E4,d, G4,d, G4,d, rest,d, ToneControl.PLAY_BLOCK, 0, // repeat "A" section D4,d, D4,d, E4,d, D4,d, C4,d // play "C" section }; try { Player p = Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR); p.realize(); ToneControl c = (ToneControl)p.getControl("ToneControl"); c.setSequence(mySequence); p.start(); } catch (IOException ioe) { } catch (MediaException me) {}
Field Summary | |
static byte |
BLOCK_END
ºí·ÏÀÇ ³¡Á¡À» Á¤ÀÇÇÕ´Ï´Ù. |
static byte |
BLOCK_START
ºí·ÏÀÇ ½ÃÀÛÁ¡À» Á¤ÀÇÇÕ´Ï´Ù. |
static byte |
C4
Áß¾Ó C 60 °ªÀÌ C4 ¿¡ ÁöÁ¤µË´Ï´Ù. |
static byte |
PLAY_BLOCK
Á¤ÀÇµÈ ºí·ÏÀ» Àç»ýÇÕ´Ï´Ù. |
static byte |
REPEAT
REPEAT À̺¥Æ® ÅÂ±× -9 °ªÀÌ REPEAT ¿¡ ÁöÁ¤µË´Ï´Ù. |
static byte |
RESOLUTION
RESOLUTION À̺¥Æ® ű×. |
static byte |
SET_VOLUME
SET_VOLUME À̺¥Æ® ű×. |
static byte |
SILENCE
¹«À½ -1 °ªÀÌ SILENCE ¿¡ ÁöÁ¤µË´Ï´Ù. |
static byte |
TEMPO
TEMPO À̺¥Æ® ű×. |
static byte |
VERSION
VERSION ¼Ó¼º ÅÂ±× -2 °ªÀÌ VERSION ¿¡ ÁöÁ¤µË´Ï´Ù. |
Method Summary | |
void |
setSequence(byte[] sequence)
Åæ ½ÃÄö½º¸¦ ¼³Á¤ÇÕ´Ï´Ù. |
Field Detail |
public static final byte VERSION
-2 °ªÀÌ VERSION
¿¡ ÁöÁ¤µË´Ï´Ù.
public static final byte TEMPO
-3 °ªÀÌ TEMPO
¿¡ ÁöÁ¤µË´Ï´Ù.
public static final byte RESOLUTION
-4 °ªÀÌ RESOLUTION
¿¡ ÁöÁ¤µË´Ï´Ù.
public static final byte BLOCK_START
-5 °ªÀÌ BLOCK_START
¿¡ ÁöÁ¤µË´Ï´Ù.
public static final byte BLOCK_END
-6 °ªÀÌ BLOCK_END
¿¡ ÁöÁ¤µË´Ï´Ù.
public static final byte PLAY_BLOCK
-7 °ªÀÌ PLAY_BLOCK
¿¡ ÁöÁ¤µË´Ï´Ù.
public static final byte SET_VOLUME
-8 °ªÀÌ SET_VOLUME
¿¡ ÁöÁ¤µË´Ï´Ù.
public static final byte REPEAT
-9 °ªÀÌ REPEAT
¿¡ ÁöÁ¤µË´Ï´Ù.
public static final byte C4
60 °ªÀÌ C4
¿¡ ÁöÁ¤µË´Ï´Ù.
public static final byte SILENCE
-1 °ªÀÌ SILENCE
¿¡ ÁöÁ¤µË´Ï´Ù.
Method Detail |
public void setSequence(byte[] sequence)
sequence
- ¼³Á¤ÇÒ ½ÃÄö½º
IllegalArgumentException
- ½ÃÄö½º°¡
null
À̰ųª À¯È¿ÇÏÁö ¾ÊÀº °æ¿ì ¹ß»ýÇÕ´Ï´Ù.
IllegalStateException
- ÀÌ ÄÁÆ®·ÑÀÌ ¼ÓÇØ ÀÖ´Â
Player
°¡ PREFETCHED ¶Ç´Â
STARTED »óÅ¿¡ ÀÖ´Â °æ¿ì ¹ß»ýÇÕ´Ï´Ù.
|
MID ÇÁ·ÎÇÊ | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |