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

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

?? midinote.cpp

?? windows CE 的BSP開發包.包含眾多的驅動程序和OAL層的開發代碼
?? CPP
字號:
// -----------------------------------------------------------------------------
//
//      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.
//      Copyright (c) 1995-2000 Microsoft Corporation.  All rights reserved.
//
// -----------------------------------------------------------------------------

#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一区二区三区免费野_久草精品视频
在线一区二区观看| 久久国产精品99精品国产 | 99综合影院在线| 欧美色视频一区| 麻豆国产91在线播放| 一区二区三区精品视频| 国产清纯美女被跳蛋高潮一区二区久久w | av在线播放一区二区三区| 日韩不卡在线观看日韩不卡视频| 国产精品国产三级国产aⅴ中文 | 色播五月激情综合网| 美女性感视频久久| 亚洲国产精品一区二区久久恐怖片 | 蜜桃av一区二区| 午夜日韩在线观看| 最新国产成人在线观看| 国产午夜精品一区二区三区四区 | 欧美日韩成人在线一区| 91片在线免费观看| 成人性生交大片免费看在线播放| 久久成人免费电影| 日韩高清国产一区在线| 夜夜嗨av一区二区三区中文字幕| 中文字幕亚洲视频| 亚洲国产高清aⅴ视频| 久久只精品国产| 国产精品久久夜| 2017欧美狠狠色| 亚洲精品一区二区在线观看| 日韩一区二区在线免费观看| 欧美伦理视频网站| 欧美精品久久久久久久多人混战 | 日本午夜精品视频在线观看| 亚洲国产精品精华液网站| 一区二区三区四区激情| 亚洲欧美另类小说视频| 亚洲精品乱码久久久久久黑人| 亚洲图片激情小说| 国产精品国产三级国产a| 国产精品久久久久影院色老大| 国产亚洲成av人在线观看导航| 久久久精品天堂| 久久久久久久久久久久电影| 久久久久国产精品厨房| 日本一区二区三区四区| 国产精品系列在线| 亚洲麻豆国产自偷在线| 亚洲精品免费在线观看| 亚洲一级不卡视频| 日韩国产高清在线| 狠狠色丁香婷综合久久| 国产高清精品网站| 97久久精品人人做人人爽 | 欧美电影影音先锋| 日韩丝袜情趣美女图片| 精品裸体舞一区二区三区| 精品播放一区二区| 国产亚洲精品bt天堂精选| 中文字幕精品一区| 一区二区三区四区五区视频在线观看 | 亚洲精品视频一区| 天堂成人免费av电影一区| 男女视频一区二区| 国产精品综合视频| 色婷婷综合在线| 欧美蜜桃一区二区三区| 欧美刺激脚交jootjob| 久久久91精品国产一区二区三区| 国产精品美日韩| 亚洲成人资源在线| 国产在线一区观看| 日韩欧美国产三级电影视频| 久久毛片高清国产| 亚洲日本丝袜连裤袜办公室| 亚洲午夜激情av| 久久精品二区亚洲w码| 成人亚洲一区二区一| 欧美日韩亚州综合| 久久综合久久综合亚洲| 一区二区三区欧美日| 毛片不卡一区二区| av电影在线观看一区| 911精品国产一区二区在线| 久久久久久一二三区| 亚洲激情成人在线| 激情六月婷婷久久| 91久久精品一区二区二区| 精品福利一二区| 亚洲一区二区视频在线| 韩国一区二区在线观看| 色欧美片视频在线观看| 久久午夜色播影院免费高清| 亚洲国产综合在线| 成人性生交大片免费看视频在线 | 成人午夜av电影| 91精品国产福利| 成人欧美一区二区三区白人| 免费高清在线视频一区·| 97久久久精品综合88久久| 26uuu欧美| 亚洲一区二区美女| 成人h动漫精品一区二| 欧美va亚洲va| 日韩精品一二三| 91久久一区二区| 国产精品美女久久久久av爽李琼| 麻豆国产精品官网| 欧洲一区二区av| 自拍偷拍国产亚洲| 高清国产一区二区三区| 日韩欧美123| 日韩电影一区二区三区| 在线免费一区三区| 国产精品国产a| 高清在线不卡av| 久久亚洲一区二区三区四区| 秋霞影院一区二区| 欧美怡红院视频| 亚洲乱码国产乱码精品精的特点| 国产一区二区三区黄视频 | 自拍偷在线精品自拍偷无码专区 | 6080国产精品一区二区| 洋洋成人永久网站入口| 一本一道综合狠狠老| 中文字幕一区二区三区蜜月| 国产69精品一区二区亚洲孕妇 | 久久国产三级精品| 777色狠狠一区二区三区| 亚洲一区二区成人在线观看| 91女人视频在线观看| 自拍偷自拍亚洲精品播放| 99re6这里只有精品视频在线观看| 欧美国产国产综合| 东方aⅴ免费观看久久av| 中文字幕不卡的av| av一二三不卡影片| 亚洲三级在线免费| 一本到不卡免费一区二区| 一区二区三区 在线观看视频| 91国偷自产一区二区三区观看| 亚洲另类在线一区| 欧美性受xxxx| 日本成人中文字幕| 欧美精品一区二区久久久 | 欧美自拍偷拍午夜视频| 亚洲精品国产视频| 欧美做爰猛烈大尺度电影无法无天| 亚洲综合自拍偷拍| 欧美日韩在线不卡| 日本不卡123| 精品国产第一区二区三区观看体验| 国内偷窥港台综合视频在线播放| 久久综合国产精品| 成人深夜在线观看| 亚洲精品国产无天堂网2021| 欧美午夜影院一区| 久久精品二区亚洲w码| 国产目拍亚洲精品99久久精品| 99re免费视频精品全部| 亚洲电影欧美电影有声小说| 欧美日韩久久一区二区| 狠狠色狠狠色综合| 国产精品成人免费精品自在线观看| 91高清在线观看| 麻豆精品一区二区综合av| 亚洲国产精品99久久久久久久久 | 国产精品美女久久久久久久| 一本久久综合亚洲鲁鲁五月天| 天天免费综合色| 国产欧美日韩另类视频免费观看| 色综合天天综合网天天狠天天| 亚洲国产欧美一区二区三区丁香婷| 日韩一卡二卡三卡| 99久久精品国产一区二区三区| 91天堂素人约啪| 五月天丁香久久| 国产精品天干天干在线综合| 欧美日韩一区二区三区在线看| 国内成人免费视频| 一区二区成人在线| 精品国产乱码久久久久久1区2区 | 在线亚洲精品福利网址导航| 麻豆精品国产91久久久久久| 亚洲色图欧洲色图婷婷| 日韩久久久精品| 色激情天天射综合网| 久久成人羞羞网站| 一区二区三区中文在线| 久久免费的精品国产v∧| 欧美视频在线观看一区二区| 国产成人精品一区二区三区四区 | 蜜臀va亚洲va欧美va天堂| 国产精品久久久久久亚洲毛片| 宅男噜噜噜66一区二区66| av不卡在线播放| 国产乱码精品一品二品| 婷婷夜色潮精品综合在线| 中文字幕中文在线不卡住| 欧美成人一区二区三区| 欧美色综合影院|