亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? midinote.cpp

?? 基于WINCE 的音頻驅動源碼
?? CPP
字號:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
// -----------------------------------------------------------------------------
//
//      THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//      ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//      THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//      PARTICULAR PURPOSE.
//
// -----------------------------------------------------------------------------

#include "wavemain.h"

// x is the desired frequency
#define FREQRATIO(x) (double(x)/double(SAMPLERATE))

#define PITCH(x)    ( (UINT32 ) ( FREQRATIO(x) * double(1i64 << 32)) )

#define EQUAL       (1.059463094359)
#ifdef EUROPE
    #define  A      (442.0)
#else
    #define  A      (440.0)
#endif
#define ASHARP      (A * EQUAL)
#define B           (ASHARP * EQUAL)
#define C           (B * EQUAL / 2.0)
#define CSHARP      (C * EQUAL)
#define DNOTE       (CSHARP * EQUAL)
#define DSHARP      (DNOTE * EQUAL)
#define E           (DSHARP * EQUAL)
#define F           (E * EQUAL)
#define FSHARP      (F * EQUAL)
#define G           (FSHARP * EQUAL)
#define GSHARP      (G * EQUAL)

// pitch values, from middle c to octave above
const UINT32 CMidiNote::PitchTable[ 12 ] =
{
    PITCH(C),
    PITCH(CSHARP),
    PITCH(DNOTE),
    PITCH(DSHARP),
    PITCH(E),
    PITCH(F),
    PITCH(FSHARP),
    PITCH(G),
    PITCH(GSHARP),
    PITCH(A),
    PITCH(ASHARP),
    PITCH(B)
};

const INT16 CMidiNote::SineTable[0x101] =
{
0,
804,
1607,
2410,
3211,
4011,
4807,
5601,
6392,
7179,
7961,
8739,
9511,
10278,
11038,
11792,
12539,
13278,
14009,
14732,
15446,
16150,
16845,
17530,
18204,
18867,
19519,
20159,
20787,
21402,
22004,
22594,
23169,
23731,
24278,
24811,
25329,
25831,
26318,
26789,
27244,
27683,
28105,
28510,
28897,
29268,
29621,
29955,
30272,
30571,
30851,
31113,
31356,
31580,
31785,
31970,
32137,
32284,
32412,
32520,
32609,
32678,
32727,
32757,
32767,
32757,
32727,
32678,
32609,
32520,
32412,
32284,
32137,
31970,
31785,
31580,
31356,
31113,
30851,
30571,
30272,
29955,
29621,
29268,
28897,
28510,
28105,
27683,
27244,
26789,
26318,
25831,
25329,
24811,
24278,
23731,
23169,
22594,
22004,
21402,
20787,
20159,
19519,
18867,
18204,
17530,
16845,
16150,
15446,
14732,
14009,
13278,
12539,
11792,
11038,
10278,
9511,
8739,
7961,
7179,
6392,
5601,
4807,
4011,
3211,
2410,
1607,
804,
0,
-804,
-1607,
-2410,
-3211,
-4011,
-4807,
-5601,
-6392,
-7179,
-7961,
-8739,
-9511,
-10278,
-11038,
-11792,
-12539,
-13278,
-14009,
-14732,
-15446,
-16150,
-16845,
-17530,
-18204,
-18867,
-19519,
-20159,
-20787,
-21402,
-22004,
-22594,
-23169,
-23731,
-24278,
-24811,
-25329,
-25831,
-26318,
-26789,
-27244,
-27683,
-28105,
-28510,
-28897,
-29268,
-29621,
-29955,
-30272,
-30571,
-30851,
-31113,
-31356,
-31580,
-31785,
-31970,
-32137,
-32284,
-32412,
-32520,
-32609,
-32678,
-32727,
-32757,
-32767,
-32757,
-32727,
-32678,
-32609,
-32520,
-32412,
-32284,
-32137,
-31970,
-31785,
-31580,
-31356,
-31113,
-30851,
-30571,
-30272,
-29955,
-29621,
-29268,
-28897,
-28510,
-28105,
-27683,
-27244,
-26789,
-26318,
-25831,
-25329,
-24811,
-24278,
-23731,
-23169,
-22594,
-22004,
-21402,
-20787,
-20159,
-19519,
-18867,
-18204,
-17530,
-16845,
-16150,
-15446,
-14732,
-14009,
-13278,
-12539,
-11792,
-11038,
-10278,
-9511,
-8739,
-7961,
-7179,
-6392,
-5601,
-4807,
-4011,
-3211,
-2410,
-1607,
-804,
0   // Extra sample here saves 1 instruction in interpolation case
};

void CMidiNote::GainChange()
{
    m_fxpGain = m_pMidiStream->MapNoteGain(m_dwGain);
}

HRESULT CMidiNote::NoteOn(CMidiStream *pMidiStream, UINT32 Note, UINT32 Velocity, UINT32 Channel)
{
    // Save params
    m_pMidiStream = pMidiStream;
    m_Note     = Note;
    m_Channel  = Channel;
    SetVelocity(Velocity);

    // Init pitch
    m_Index = 0;
    if (Channel==FREQCHANNEL)
    {
        m_IndexDelta = (Note * INVSAMPLERATE);
    }
    else
    {
        m_IndexDelta = PitchTable[ Note % 12 ] ;

        // Adjust octave
        int Octave = ((int)(Note/12)) - 5;
        if (Octave>0)
        {
            m_IndexDelta <<= Octave;
        }
        else if (Octave<0)
        {
            m_IndexDelta >>= -Octave;
        }
    }

    return S_OK;
}

HRESULT CMidiNote::NoteOff(UINT32 Velocity)
{
    // Calculate the number of samples left before we cross a 0 boundary at the middle or end of the table
    DWORD SamplesLeft = ( ((0-m_Index)&0x7FFFFFFF) /m_IndexDelta) + 1;
    m_dwBytesLeft = SamplesLeft * sizeof(HWSAMPLE) * OUTCHANNELS;
    DEBUGMSG(1, (TEXT("CMidiNote::NoteOff, m_Index = 0x%x, m_IndexDelta = 0x%x, m_dwBytesLeft = %d\r\n"),m_Index,m_IndexDelta,m_dwBytesLeft));
    // m_pMidiStream->NoteDone(this);
    return S_OK;
}

PBYTE CMidiNote::Render(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
{
    DWORD BytesLeft = m_dwBytesLeft;

    // Handle common case first
    if (BytesLeft==(DWORD)-1)
    {
        // Call real inner loop
        return Render2(pBuffer,pBufferEnd,pBufferLast);
    }

    DEBUGMSG(1, (TEXT("CMidiNote::Render, Note in release, m_dwBytesLeft = %d\r\n"),BytesLeft));

    DWORD BytesThisBuf = (pBufferEnd-pBuffer);
    if (BytesLeft > BytesThisBuf)
    {
        // If we can't end during this buffer, just remember where we were
        BytesLeft-=BytesThisBuf;
    }
    else
    {
        // Ok, we end during this buffer. Update pBufferEnd to force the renderer to stop on a 0 crossing.
        pBufferEnd = pBuffer + BytesLeft;
        BytesLeft=0;
    }

    m_dwBytesLeft = BytesLeft;

    // Call real inner loop
    pBufferLast = Render2(pBuffer,pBufferEnd,pBufferLast);

    if (BytesLeft==0)
    {
        // Time to end the note.
        DEBUGMSG(1, (TEXT("CMidiNote::Render, Last index after note done = 0x%x\r\n"),m_Index));
        m_pMidiStream->NoteDone(this);
    }

    return pBufferLast;
}

// Inner loop of the note renderer.
PBYTE CMidiNote::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
{
    // Cache values so compiler won't worry about aliasing
    UINT32 Index            = m_Index;
    UINT32 IndexDelta       = m_IndexDelta;
    const INT16 * pSineTable = SineTable;
    LONG fxpGain = m_fxpGain;

    while (pBuffer < pBufferEnd)
    {
        // Index is in 8.24 format, where the top 8 bits index into the sine table and
        // the lower 24 bits represent the fraction of where we sit between two adjacent
        // samples, which we can use if we're doing linear interpolation
        // I chose 8.24 format so that wrap around at the top of the table happens
        // automatically without the need to do any ANDing.

        // Get an index into the sine table and look up the sample.
        UINT32 TableIndex = Index>>24;
        INT32 OutSamp0 = pSineTable[TableIndex];

#if MIDI_OPTIMIZE_LINEAR_INTERPOLATE
        // If we're doing linear interpolation, get the next sample also. Note that I don't
        // need to worry about wrap around at the top of the table because the sine table has
        // an extra value tacked onto the end to handle this special case.
        INT32 NextSamp = pSineTable[TableIndex+1];

        // Now do the interpolation, adjusting the index to be in 24.8 format and throwing away
        // the integer part (e.g. interpolate 256 points between samples).
        OutSamp0 += ( (NextSamp - OutSamp0) * ((Index>>16)&0x00FF) ) >> 8;
#endif

        // Increment the index to move to the next sample
        // and keep within the valid range
        Index += IndexDelta;

        // Volume!
        OutSamp0 = (OutSamp0 * fxpGain) >> VOLSHIFT;
#if (OUTCHANNELS==2)
        INT32 OutSamp1;
        OutSamp1=OutSamp0;
        if (pBuffer < pBufferLast)
        {
            OutSamp0 += ((HWSAMPLE *)pBuffer)[0];
            OutSamp1 += ((HWSAMPLE *)pBuffer)[1];
#if USE_MIX_SATURATE
            // Handle saturation
            if (OutSamp0>AUDIO_SAMPLE_MAX)
            {
                OutSamp0=AUDIO_SAMPLE_MAX;
            }
            else if (OutSamp0<AUDIO_SAMPLE_MIN)
            {
                OutSamp0=AUDIO_SAMPLE_MIN;
            }
            if (OutSamp1>AUDIO_SAMPLE_MAX)
            {
                OutSamp1=AUDIO_SAMPLE_MAX;
            }
            else if (OutSamp1<AUDIO_SAMPLE_MIN)
            {
                OutSamp1=AUDIO_SAMPLE_MIN;
            }
#endif
        }
        ((HWSAMPLE *)pBuffer)[0] = (HWSAMPLE)OutSamp0;
        ((HWSAMPLE *)pBuffer)[1] = (HWSAMPLE)OutSamp1;
        pBuffer += 2*sizeof(HWSAMPLE);
#else
        if (pBuffer<pBufferLast)
        {
            // Store/sum to the output buffer
            OutSamp0 += *(HWSAMPLE *)pBuffer;

#if USE_MIX_SATURATE
            // Handle saturation
            if (OutSamp0>AUDIO_SAMPLE_MAX)
            {
                OutSamp0=AUDIO_SAMPLE_MAX;
            }
            else if (OutSamp0<AUDIO_SAMPLE_MIN)
            {
                OutSamp0=AUDIO_SAMPLE_MIN;
            }
#endif
        }
        ((HWSAMPLE *)pBuffer)[0] = (HWSAMPLE)OutSamp0;
        pBuffer+=sizeof(HWSAMPLE);
#endif
    }

    // Save cached settings that might have changed in the inner loop
    m_Index = Index;

    return pBuffer;
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人免费视频视频在线观看免费 | 久久久美女艺术照精彩视频福利播放| 视频在线在亚洲| 日韩美女视频19| 久久天堂av综合合色蜜桃网| 91精品国产一区二区三区| 成人午夜在线播放| 国产伦精品一区二区三区免费| 亚洲欧美精品午睡沙发| 日韩视频不卡中文| 欧美一区二区三区视频免费播放 | 日韩欧美美女一区二区三区| 欧美日韩中文国产| 色欧美日韩亚洲| 一区二区三区中文字幕电影| 91视视频在线观看入口直接观看www | 久久免费看少妇高潮| 国产精品天干天干在线综合| 亚洲已满18点击进入久久| 精品一区二区三区免费视频| 国内精品久久久久影院色| 国产成人精品影院| 欧美日韩三级一区二区| 精品欧美一区二区三区精品久久| 久久久五月婷婷| 亚洲国产精品久久一线不卡| 国产成人免费高清| 51久久夜色精品国产麻豆| 国产亚洲综合性久久久影院| 天堂av在线一区| 97aⅴ精品视频一二三区| 欧美日韩国产乱码电影| 久久精品视频免费观看| 亚洲成a人片综合在线| 国产麻豆精品久久一二三| 色域天天综合网| 精品成人在线观看| 久久综合久色欧美综合狠狠| 国产精品久久久久久久第一福利 | 国产欧美日韩综合精品一区二区| 午夜国产精品影院在线观看| 91蝌蚪porny九色| 久久久综合九色合综国产精品| 日韩一区精品字幕| 国产一区二区不卡在线| 丁香网亚洲国际| 26uuu国产一区二区三区| 免费观看成人鲁鲁鲁鲁鲁视频| 91福利视频在线| 亚洲男人天堂av| 成人av电影免费观看| 国产亚洲综合在线| 日韩国产精品久久久久久亚洲| 色综合激情五月| 亚洲精品视频观看| 白白色亚洲国产精品| 欧美激情一区在线观看| 精品一区二区三区日韩| 欧美videossexotv100| 人妖欧美一区二区| 日韩精品一区二区在线| 国产成人日日夜夜| 日韩电影在线一区| 91精品国产综合久久久久久| 同产精品九九九| 精品美女在线观看| 国产激情精品久久久第一区二区| 久久综合视频网| www.日韩大片| 夜夜夜精品看看| 日韩亚洲欧美一区| 国产一区二区精品久久99| 中文字幕欧美三区| 成人av电影在线| 亚洲免费观看在线观看| 欧美视频在线观看一区二区| 奇米影视7777精品一区二区| 久久综合一区二区| 色婷婷av一区| 男女性色大片免费观看一区二区| 久久精品视频在线免费观看| jiyouzz国产精品久久| 亚洲午夜精品在线| 久久这里只有精品视频网| jlzzjlzz国产精品久久| 日本一道高清亚洲日美韩| 国产精品午夜在线观看| 欧美绝品在线观看成人午夜影视| 精品午夜久久福利影院 | 91麻豆精品视频| 五月天精品一区二区三区| 久久先锋影音av鲁色资源网| 色综合色综合色综合色综合色综合| 日韩中文字幕区一区有砖一区 | 日韩欧美亚洲一区二区| www.视频一区| 美洲天堂一区二卡三卡四卡视频| 国产欧美视频一区二区| 欧美日韩专区在线| 国产黄色91视频| 亚洲成人综合网站| 国产精品国产三级国产aⅴ中文| 欧美日韩国产不卡| 91无套直看片红桃| 国产精品资源网| 肉肉av福利一精品导航| ...xxx性欧美| 久久久另类综合| 正在播放亚洲一区| 欧美亚洲国产怡红院影院| 激情六月婷婷久久| 日日摸夜夜添夜夜添精品视频| 中文字幕在线不卡| 久久久一区二区三区| 69成人精品免费视频| 色女孩综合影院| 成人av资源在线观看| 五月天视频一区| 亚洲精品乱码久久久久久日本蜜臀| 久久免费视频色| 欧美va亚洲va在线观看蝴蝶网| 欧美视频在线观看一区| 99精品视频中文字幕| 国产98色在线|日韩| 国产一区二区三区在线观看免费| 日韩电影在线免费看| 国产精品每日更新| 国产人久久人人人人爽| 久久免费午夜影院| 久久亚洲免费视频| 精品国产乱码久久久久久免费| 3d成人h动漫网站入口| 欧美日韩一区成人| 欧美精品在欧美一区二区少妇| 欧美在线综合视频| 国产色一区二区| 日韩一区二区在线观看视频| 91久久一区二区| 色婷婷久久一区二区三区麻豆| 国产主播一区二区| 国产麻豆精品在线观看| 国产成人av一区二区三区在线观看| 国产一区二区在线影院| 国产高清亚洲一区| 成人一区二区在线观看| 成人av集中营| 在线观看亚洲成人| 99国内精品久久| 91成人网在线| 91精品国模一区二区三区| 日韩欧美一区中文| 欧美激情一区二区三区四区| 国产精品国产三级国产专播品爱网 | 美女一区二区三区| 国产精品一区二区男女羞羞无遮挡| 国产成人免费视频一区| 99久久精品国产观看| 欧美揉bbbbb揉bbbbb| 欧美一级免费大片| 欧美韩国一区二区| 亚洲一区二区三区四区五区中文| 亚洲1区2区3区视频| 免费观看一级特黄欧美大片| 一本色道综合亚洲| 国产99久久久久| 欧美美女一区二区| 亚洲欧洲av一区二区三区久久| 五月天一区二区三区| av一区二区久久| 欧美精品一区二区三区在线| 亚洲自拍偷拍麻豆| 国产69精品久久99不卡| 欧美精品xxxxbbbb| 国产乱人伦偷精品视频不卡| 日本大香伊一区二区三区| 国产欧美一区二区精品性| 美女性感视频久久| 欧美挠脚心视频网站| 亚洲视频在线一区| 国产91精品一区二区| 欧美tickling网站挠脚心| 亚洲午夜久久久久久久久电影院| 国产v日产∨综合v精品视频| 精品国产一区二区精华| 日韩精品免费专区| 欧美视频第二页| 一区二区不卡在线视频 午夜欧美不卡在| 国产在线播放一区三区四| 欧美一级免费大片| 日韩有码一区二区三区| 欧美色图片你懂的| 一区二区三区日韩精品视频| 99久久精品费精品国产一区二区| 国产婷婷色一区二区三区| 国产一区二区在线看| 久久亚洲二区三区| 国产精品一区专区| 国产日韩精品久久久| 高清成人免费视频| 国产精品久久99|