| 1 |
/* |
| 2 |
Copyright (c) 2009, hkrn All rights reserved. |
| 3 |
|
| 4 |
Redistribution and use in source and binary forms, with or without |
| 5 |
modification, are permitted provided that the following conditions are met: |
| 6 |
|
| 7 |
Redistributions of source code must retain the above copyright notice, this |
| 8 |
list of conditions and the following disclaimer. Redistributions in binary |
| 9 |
form must reproduce the above copyright notice, this list of conditions and |
| 10 |
the following disclaimer in the documentation and/or other materials |
| 11 |
provided with the distribution. Neither the name of the hkrn nor |
| 12 |
the names of its contributors may be used to endorse or promote products |
| 13 |
derived from this software without specific prior written permission. |
| 14 |
|
| 15 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 16 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 |
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR |
| 19 |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 20 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 21 |
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 22 |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 23 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 24 |
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 25 |
DAMAGE. |
| 26 |
*/ |
| 27 |
|
| 28 |
// |
| 29 |
// $Id$ |
| 30 |
// |
| 31 |
|
| 32 |
using System; |
| 33 |
|
| 34 |
namespace SlMML |
| 35 |
{ |
| 36 |
public static class Sample |
| 37 |
{ |
| 38 |
#region ��������������� |
| 39 |
public const int RATE = 44100; |
| 40 |
public const int FREQUENCY_BASE = 440; |
| 41 |
#endregion |
| 42 |
|
| 43 |
#region ��������������������������� |
| 44 |
/// <summary> |
| 45 |
/// ���������������������������16bit��������������������������� |
| 46 |
/// </summary> |
| 47 |
/// <remarks> |
| 48 |
/// ���������������������������������������double������������������������������������ |
| 49 |
/// GetSampleAsync���double������16bit������������(16bitPCM)������������������������ |
| 50 |
/// </remarks> |
| 51 |
/// <param name="s">������������������������������</param> |
| 52 |
/// <returns>16bit������������</returns> |
| 53 |
public static short ToShort(this double s) |
| 54 |
{ |
| 55 |
return (short)Math.Round(s * 16384); |
| 56 |
} |
| 57 |
#endregion |
| 58 |
} |
| 59 |
} |