⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tonecontrol.html

📁 J2ME MIDP2.0 final specification
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Fri Sep 27 14:47:31 CDT 2002 --><TITLE>Mobile Information Device Profile 2.0: Interface  ToneControl</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/ToneControl.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><strong>MIDP 2.0</strong></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;PREV CLASS&nbsp;&nbsp;<A HREF="../../../../javax/microedition/media/control/VolumeControl.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="ToneControl.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.microedition.media.control</FONT><BR>Interface  ToneControl</H2><DL><DT><B>All Superinterfaces:</B> <DD><A HREF="../../../../javax/microedition/media/Control.html">Control</A></DD></DL><HR><DL><DT>public interface <B>ToneControl</B><DT>extends <A HREF="../../../../javax/microedition/media/Control.html">Control</A></DL><P><code>ToneControl</code> is the interface to enable playback of a  user-defined monotonic tone sequence. <p> A tone sequence is specified as a list of tone-duration pairs and user-defined sequence blocks.  The list is packaged as an  array of bytes.  The <code>setSequence</code> method is used to  input the sequence to the <code>ToneControl</code>. <p> The syntax of a tone sequence is described in  <a href="http://www.ietf.org/rfc/rfc2234">Augmented BNF</a> notations: <blockquote> <pre> 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. </pre> </blockquote>  <A HREF="#VERSION"><code>VERSION</code></A>,  <A HREF="#TEMPO"><code>TEMPO</code></A>,  <A HREF="#RESOLUTION"><code>RESOLUTION</code></A>,  <A HREF="#BLOCK_START"><code>BLOCK_START</code></A>,  <A HREF="#BLOCK_END"><code>BLOCK_END</code></A>,  <A HREF="#PLAY_BLOCK"><code>PLAY_BLOCK</code></A> <A HREF="#SET_VOLUME"><code>SET_VOLUME</code></A> <A HREF="#REPEAT"><code>REPEAT</code></A> are pre-defined constants. <p> Following table shows the valid range of the parameters: <blockquote> <table border=1> <tr>   <td align="center">Parameter</td>   <td align="center">Valid Range</td>   <td align="center">Effective Range</td>   <td align="center">Default</td></tr> <tr>   <td><code>tempo_modifier</code></td>   <td align="center">5<= <code>tempo_modifier</code> <= 127 </td>   <td align="center">20bpm to 508bpm</td>   <td align="center">120bpm</td></tr> <tr>   <td><code>resolution_unit</code></td>   <td align="center">1<= <code>resolution_unit</code> <= 127 </td>   <td align="center">1/1 note to 1/127 note</td>   <td align="center">1/64 note</td></tr> <tr>   <td><code>block_number</code></td>   <td align="center">0<= <code>block_number</code> <= 127</td>   <td align="center"> - </td>   <td align="center"> - </td></tr> <tr>   <td><code>note</code></td>   <td align="center">0<= <code>note</code> <= 127 or        <A HREF="#SILENCE"<code>SILENCE</code></a></td>   <td align="center">C-1 to G9 or rest</td>   <td align="center"> - </td></tr> <tr>   <td><code>duration</code></td>   <td align="center">1<= <code>duration</code> <= 127 </td>   <td align="center"> - </td>   <td align="center"> - </td></tr> <tr>   <td><code>volume</code></td>   <td align="center">0<= <code>volume</code> <= 100 </td>   <td align="center">0% to 100% volume</td>   <td align="center">100%</td></tr> <tr>   <td><code>multiplier</code></td>   <td align="center">2<= <code>multiplier</code> <= 127 </td>   <td align="center"> - </td>   <td align="center"> - </td></tr> </table> <br> </blockquote> The frequency  of the note can be calculated from the following formula: <pre>     SEMITONE_CONST = 17.31234049066755 = 1/(ln(2^(1/12)))     note = ln(freq/8.176)*SEMITONE_CONST </pre> The musical note A = note 69 (0x45) = 440 Hz. <br> <A HREF="#C4">Middle C (C4)</A> and <A HREF="#SILENCE">SILENCE</A> are defined as constants. <p> The duration of each tone is measured in units of 1/resolution notes and tempo is specified in beats/minute, where 1 beat = 1/4 note.  Because the range of positive values of <code>byte</code> is only 1 - 127, the tempo is  formed by multiplying the tempo modifier by 4. Very slow tempos  are excluded so range of tempo modifiers is 5 - 127 providing an  effective range of 20 - 508 bpm. <p> To compute the effective duration in milliseconds for a tone,  the following formula can be used: <pre>     duration * 60 * 1000 * 4 / (resolution * tempo) </pre>  The following table lists some common durations in musical notes: <blockquote> <table border=1> <tr>   <td align="center">Note Length</td>   <td align="center">Duration, Resolution=64</td>   <td align="center">Duration, Resolution=96</td></tr> <tr>   <td align="center">1/1</td>   <td align="center">64</td>   <td align="center">96</td></tr> <tr>   <td align="center">1/4</td>   <td align="center">16</td>   <td align="center">24</td></tr> <tr>   <td align="center">1/4 dotted</td>   <td align="center">24</td>   <td align="center">36</td></tr> <tr>   <td align="center">1/8</td>   <td align="center">8</td>   <td align="center">12</td></tr> <tr>   <td align="center">1/8 triplets</td>   <td align="center">-</td>   <td align="center">8</td></tr> <tr>   <td align="center">4/1</td>   <td align="center"><code>REPEAT</code> 4 &lt;note&gt; 64</td>   <td align="center"><code>REPEAT</code> 4 &lt;note&gt; 96</td> </table> </blockquote> <h2>Example</h2> <blockquote> <pre>    // "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) { } </pre> </blockquote><P><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== -->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -