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

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

?? midinote.cpp

?? 包含了大量文件
?? 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一区二区三区免费野_久草精品视频
久久色视频免费观看| 日韩国产精品大片| 亚洲午夜激情av| 国产乱人伦偷精品视频不卡| 色哟哟精品一区| 久久久久国产免费免费| 亚洲国产视频一区二区| 成人动漫av在线| 日韩欧美在线影院| 亚洲成人av中文| av午夜精品一区二区三区| 精品美女一区二区| 亚洲午夜久久久久| 色视频成人在线观看免| 国产女同互慰高潮91漫画| 美女久久久精品| 欧美日韩中字一区| 自拍偷拍欧美激情| 国产精品66部| 精品国偷自产国产一区| 日韩 欧美一区二区三区| 97久久精品人人做人人爽50路| 精品国产一区二区三区忘忧草| 午夜精品久久久久久久久久| 色婷婷精品久久二区二区蜜臂av| 欧美激情一区二区三区四区| 极品少妇xxxx精品少妇| 91精品国产91热久久久做人人| 亚洲自拍另类综合| 一本大道久久a久久精二百| 国产精品每日更新在线播放网址| 韩国av一区二区三区在线观看| 91精品国产高清一区二区三区蜜臀| 亚洲国产cao| 欧美日韩小视频| 午夜精品福利在线| 在线播放亚洲一区| 蜜臀久久99精品久久久久久9 | 日韩一区二区三区av| 亚洲va欧美va国产va天堂影院| 在线一区二区观看| 夜夜爽夜夜爽精品视频| 欧美色综合天天久久综合精品| 一级特黄大欧美久久久| 2020国产精品自拍| 麻豆精品视频在线观看免费 | 久久综合一区二区| 国产在线一区二区综合免费视频| 日韩精品一区二区三区视频播放| 久久99久久精品| 久久夜色精品一区| 成人理论电影网| 亚洲图片另类小说| 欧美色网站导航| 热久久久久久久| 久久伊人蜜桃av一区二区| 国产精品99久久久久久似苏梦涵| 国产欧美日韩不卡| 色94色欧美sute亚洲13| 亚洲国产aⅴ天堂久久| 欧美电影免费观看高清完整版在线观看 | 亚洲另类中文字| 欧美日韩国产首页| 久久精品国产第一区二区三区| 久久久久久久一区| 91香蕉视频在线| 亚洲第四色夜色| 久久无码av三级| 91尤物视频在线观看| 亚洲自拍欧美精品| 337p日本欧洲亚洲大胆色噜噜| 国产91精品在线观看| 一二三四社区欧美黄| 日韩精品在线一区二区| 欧美日韩一区二区三区在线看| 激情综合五月婷婷| 亚洲欧美福利一区二区| 欧美一区二区久久| 91视频.com| 韩国成人福利片在线播放| 1000部国产精品成人观看| 91麻豆精品国产91久久久更新时间| 国产真实乱对白精彩久久| 亚洲欧美另类小说视频| 精品第一国产综合精品aⅴ| 91尤物视频在线观看| 久久国产精品免费| 亚洲一区二区av电影| 日本一区二区视频在线观看| 欧美日韩成人综合天天影院| 成人av综合在线| 激情小说欧美图片| 亚洲成人高清在线| 国产精品不卡在线观看| 精品国产青草久久久久福利| 日本久久电影网| 成人av第一页| 国产一区视频导航| 免费在线一区观看| 一区二区三区产品免费精品久久75| 久久综合成人精品亚洲另类欧美 | 一区二区三区鲁丝不卡| 国产午夜亚洲精品不卡| 欧美精品一卡二卡| 欧美专区日韩专区| 成人app下载| 丁香桃色午夜亚洲一区二区三区| 91碰在线视频| 国产成人午夜视频| 久久精品久久久精品美女| 亚洲成人综合网站| 一级精品视频在线观看宜春院| 国产精品久线在线观看| 国产欧美日韩精品在线| 国产午夜精品一区二区| 精品成人在线观看| 欧美v国产在线一区二区三区| 欧美另类videos死尸| 欧美日韩一区二区三区四区| 欧美在线视频你懂得| 色婷婷久久综合| 欧美日韩在线播放| 一本大道久久a久久综合| 在线区一区二视频| 欧美午夜片在线看| 欧美色视频一区| 欧美精品tushy高清| 在线观看91av| 亚洲精品一区二区三区四区高清| 欧美大片拔萝卜| 久久夜色精品一区| 欧美激情中文不卡| 一区二区三区欧美激情| 亚洲电影中文字幕在线观看| 日韩成人午夜电影| 国产综合色在线视频区| 国产福利精品导航| 91在线精品一区二区三区| 91免费国产在线| 欧美天天综合网| 日韩免费一区二区| 国产亚洲一二三区| 国产精品不卡视频| 午夜精品久久一牛影视| 色八戒一区二区三区| 欧美久久免费观看| 久久久国产精品午夜一区ai换脸| 国产精品视频免费看| 亚洲尤物在线视频观看| 蜜臂av日日欢夜夜爽一区| 国产电影一区二区三区| 色婷婷国产精品综合在线观看| 欧美肥妇bbw| 欧美国产国产综合| 亚洲一级不卡视频| 国产精品中文字幕欧美| 91精品福利视频| 欧美videos大乳护士334| 中文字幕在线观看不卡视频| 亚洲国产日韩综合久久精品| 极品美女销魂一区二区三区| 99精品视频在线观看| 日韩一区二区三区视频| 亚洲欧洲精品成人久久奇米网| 石原莉奈在线亚洲二区| 成人一区在线看| 欧美性大战久久久久久久蜜臀| 亚洲精品在线免费观看视频| 一区二区三区在线观看网站| 国产一区亚洲一区| 欧美日本国产视频| 综合中文字幕亚洲| 精品一区二区三区欧美| 在线免费观看成人短视频| 久久婷婷成人综合色| 亚洲高清久久久| 成人av高清在线| 久久只精品国产| 天天色综合天天| 色悠悠久久综合| 国产校园另类小说区| 久久国产剧场电影| 欧美日韩欧美一区二区| 成人免费在线视频观看| 精品一区二区三区在线播放视频| 欧美影片第一页| 综合av第一页| www.日本不卡| 亚洲国产电影在线观看| 国产精品综合网| 日韩一区二区三区视频在线| 亚洲成人动漫在线免费观看| 91麻豆国产香蕉久久精品| 国产精品色在线| 国产精品一区一区| 久久这里只精品最新地址| 久久精品国产精品亚洲红杏| 91精品国产综合久久精品性色| 亚洲国产色一区| 欧美日韩三级在线|