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

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

?? midinote.cpp

?? 6410BSP3
?? 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(ZONE_FUNCTION, (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(ZONE_FUNCTION, (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(ZONE_FUNCTION, (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一区二区三区免费野_久草精品视频
日韩视频免费观看高清完整版在线观看 | 国产亚洲欧美日韩日本| 欧美揉bbbbb揉bbbbb| 色8久久精品久久久久久蜜| 成人性生交大片免费| 激情综合色综合久久| 麻豆国产欧美日韩综合精品二区| 免费人成精品欧美精品| 日韩国产精品大片| 韩国成人在线视频| 风间由美中文字幕在线看视频国产欧美| 国产在线日韩欧美| 高清国产一区二区| 色菇凉天天综合网| 91精品在线麻豆| 久久久精品国产免大香伊 | 不卡大黄网站免费看| 成人免费看片app下载| 91网址在线看| 3751色影院一区二区三区| 欧美一区二区三区白人| 久久久久久免费毛片精品| 综合在线观看色| 亚洲成a人片在线观看中文| 日韩中文字幕一区二区三区| 精品午夜久久福利影院| 不卡的av在线| 欧美videofree性高清杂交| 久久精品人人爽人人爽| 一区二区三区四区高清精品免费观看 | 精品国产一区二区三区久久久蜜月 | 成人三级在线视频| 中文字幕av一区二区三区高| 亚洲高清免费视频| 777奇米成人网| 欧美mv日韩mv| 日本大胆欧美人术艺术动态| 色老综合老女人久久久| 中文字幕欧美激情一区| 久久99久久99| 在线观看日韩电影| 亚洲视频精选在线| 国产一区二区精品在线观看| 久久综合给合久久狠狠狠97色69| 丝袜亚洲精品中文字幕一区| 欧美视频一区二区三区在线观看 | 国产综合色视频| 国产日韩欧美高清| 日本久久一区二区| 蜜桃视频在线观看一区二区| 国产午夜精品福利| 国产精品污污网站在线观看| 在线观看欧美日本| 美女网站色91| 欧美日韩精品一区视频| 国产精品无圣光一区二区| 日韩av在线播放中文字幕| 97se亚洲国产综合自在线不卡| 欧美第一区第二区| 亚洲第一搞黄网站| 91丨porny丨蝌蚪视频| 久久九九国产精品| 韩国一区二区三区| 日韩一区二区三免费高清| 亚洲国产综合91精品麻豆| 成人av影视在线观看| 久久精品欧美一区二区三区麻豆 | 麻豆精品在线观看| 亚洲欧美日韩一区| 欧美—级在线免费片| 精品一区二区三区久久久| 欧美日韩夫妻久久| 一区二区三区加勒比av| heyzo一本久久综合| 日本一区免费视频| 国产乱码字幕精品高清av| 精品日韩99亚洲| 老司机午夜精品99久久| 日韩欧美你懂的| 美洲天堂一区二卡三卡四卡视频| 欧美第一区第二区| 国产一区二区精品久久91| 久久综合一区二区| 国产黄色精品网站| 国产精品色哟哟| 91亚洲永久精品| 亚洲图片有声小说| 欧美日韩国产免费| 蜜臀av一区二区在线免费观看| 日韩欧美一区二区免费| 国产精品综合网| 国产精品理论片| 欧美专区在线观看一区| 日韩av网站在线观看| 精品成人a区在线观看| 国产麻豆日韩欧美久久| 亚洲欧美综合另类在线卡通| 欧洲一区在线观看| 麻豆精品视频在线| 综合激情成人伊人| 欧美视频一区二| 国产精一品亚洲二区在线视频| 日本一区二区三区电影| 欧美亚男人的天堂| 国产乱码精品一区二区三区av| 中文字幕一区二区三区蜜月| 欧美性xxxxx极品少妇| 国模一区二区三区白浆| 亚洲女与黑人做爰| 日韩精品一区二区三区蜜臀| 国产成人在线色| 日韩二区在线观看| 亚洲天堂精品在线观看| 日韩三级电影网址| 色偷偷成人一区二区三区91| 精品在线你懂的| 亚洲一区二区在线播放相泽| 久久久99久久| 欧美一区二区三区视频免费| 99久久精品国产一区| 久久精工是国产品牌吗| 一区二区欧美精品| 久久精品亚洲国产奇米99| 91精品免费观看| 色婷婷国产精品综合在线观看| 精品亚洲成a人| 日韩福利电影在线观看| 一区二区三区国产豹纹内裤在线| 久久久国际精品| 日韩美一区二区三区| 在线观看一区二区视频| 成人精品视频一区二区三区尤物| 美女网站一区二区| 日韩av电影天堂| 亚洲一区二区三区视频在线播放| 国产日产欧美一区二区三区 | 日韩欧美一区电影| 欧美日韩免费视频| 色婷婷久久99综合精品jk白丝| 韩国av一区二区三区四区| 天天影视色香欲综合网老头| 亚洲欧美日韩久久精品| 国产精品黄色在线观看| 国产丝袜在线精品| 久久久99精品免费观看不卡| 26uuu亚洲| 国产偷国产偷亚洲高清人白洁| 精品日韩99亚洲| 日韩久久久精品| 26uuu亚洲综合色欧美 | 岛国精品在线观看| 国产一区二区三区在线观看免费视频| 全部av―极品视觉盛宴亚洲| 首页国产丝袜综合| 日韩av中文字幕一区二区三区| 国产毛片精品视频| 国产成人aaaa| a4yy欧美一区二区三区| 91农村精品一区二区在线| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 亚洲伊人伊色伊影伊综合网| 亚洲激情欧美激情| 丝袜美腿一区二区三区| 日韩av二区在线播放| 久久不见久久见免费视频7 | 日韩经典中文字幕一区| 日本美女视频一区二区| 久草中文综合在线| 国产精品99久久久久久似苏梦涵| 成人高清视频免费观看| www.av精品| 欧美日韩成人一区| 精品福利av导航| 国产精品系列在线| 亚洲一区视频在线| 国产一区二区精品久久91| 91香蕉视频在线| 91精品国产免费| 国产精品欧美久久久久无广告| 亚洲免费av高清| 捆绑变态av一区二区三区| av福利精品导航| 91超碰这里只有精品国产| 久久久久久**毛片大全| 亚洲一区二区三区爽爽爽爽爽| 美腿丝袜亚洲综合| 91亚洲大成网污www| 欧美大片一区二区三区| 亚洲人成人一区二区在线观看 | 91传媒视频在线播放| 日韩亚洲电影在线| 综合亚洲深深色噜噜狠狠网站| 免费高清成人在线| 91国偷自产一区二区使用方法| 欧美xingq一区二区| 亚洲精品大片www| 国产在线国偷精品产拍免费yy| 欧美少妇一区二区| 国产精品丝袜一区| 卡一卡二国产精品|