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

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

?? midinote.cpp

?? 三星2440 cpu WINCE 5.00板級支持包
?? 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一区二区三区免费野_久草精品视频
成人免费毛片a| 美女视频网站久久| 91欧美一区二区| 亚洲免费电影在线| 欧美在线观看禁18| 同产精品九九九| 久久综合狠狠综合| 风间由美性色一区二区三区| 国产精品久久久久久久裸模| 暴力调教一区二区三区| 亚洲网友自拍偷拍| 日韩一级黄色片| 懂色中文一区二区在线播放| 中文字幕欧美一区| 欧美精品三级在线观看| 国产在线精品一区二区夜色| 国产日韩欧美一区二区三区综合| 成人午夜激情视频| 亚洲一线二线三线久久久| 日韩一级高清毛片| 91在线免费视频观看| 婷婷国产v国产偷v亚洲高清| 欧美精品一区二区久久久| 一本色道久久综合狠狠躁的推荐| 午夜精品一区二区三区免费视频| 久久久久久麻豆| 在线观看视频一区二区| 国产一区二区伦理片| 一区二区在线观看免费视频播放| 日韩欧美一区二区久久婷婷| 成人av在线一区二区三区| 亚洲成人综合视频| 中文字幕第一区| 91麻豆精品国产无毒不卡在线观看 | 亚洲天堂2016| 91精品国产高清一区二区三区| 国产成人三级在线观看| 亚洲电影欧美电影有声小说| 日本一区二区成人在线| 538在线一区二区精品国产| 成人av电影在线| 久久精品国产精品亚洲精品 | 精品入口麻豆88视频| 91视频国产观看| 国产综合色在线| 五月婷婷综合在线| 亚洲品质自拍视频| 久久久久成人黄色影片| 3d动漫精品啪啪一区二区竹菊| 波多野结衣中文字幕一区二区三区 | 欧美视频日韩视频在线观看| 粉嫩在线一区二区三区视频| 久久成人羞羞网站| 亚洲一区二区三区视频在线| 欧美国产97人人爽人人喊| 精品国产一区a| 中文字幕五月欧美| 美女一区二区视频| 亚洲香肠在线观看| 99精品黄色片免费大全| 亚洲精品国产成人久久av盗摄| 国产日韩欧美精品电影三级在线| 亚洲国产精品精华液2区45| 综合激情成人伊人| 午夜天堂影视香蕉久久| 蜜桃av噜噜一区| 成人av电影在线观看| 欧美性videosxxxxx| 日韩精品一区二区三区四区| 欧美极品少妇xxxxⅹ高跟鞋| 亚洲区小说区图片区qvod| 丝袜亚洲另类欧美| 国产一区欧美日韩| 日本高清不卡aⅴ免费网站| 欧美精品色综合| 国产欧美日韩在线看| 亚洲在线中文字幕| 久久超碰97人人做人人爱| 波多野结衣中文一区| 91精品午夜视频| 国产精品美女www爽爽爽| 亚洲综合视频网| 国产一区二区日韩精品| 欧美在线观看你懂的| 久久在线观看免费| 亚洲丶国产丶欧美一区二区三区| 精品一区二区在线看| 99re热这里只有精品免费视频| 欧美一区二区三区日韩视频| 亚洲国产电影在线观看| 日韩精品一级二级| 91亚洲午夜精品久久久久久| 日韩一级二级三级精品视频| 亚洲色图视频免费播放| 看电影不卡的网站| 91精彩视频在线观看| 国产婷婷一区二区| 日韩电影免费一区| 91亚洲国产成人精品一区二三| 欧美r级电影在线观看| 亚洲影院在线观看| 成人av资源在线| 久久久综合视频| 日本人妖一区二区| 欧美色国产精品| 亚洲精品视频观看| 丁香激情综合国产| 欧美r级电影在线观看| 首页国产丝袜综合| 色哟哟欧美精品| 中文字幕一区二区三区不卡在线| 另类小说视频一区二区| 在线不卡的av| 亚洲小说欧美激情另类| av中文一区二区三区| 国产亚洲欧美中文| 久久国产精品72免费观看| 欧美性三三影院| 亚洲女与黑人做爰| 91免费在线看| 最新热久久免费视频| 成人av资源在线| 国产精品美女一区二区| 国产成人在线电影| 国产亚洲欧美激情| 国产成人福利片| 国产欧美一区二区三区网站| 久久66热偷产精品| 精品久久久久久久久久久久久久久 | 在线亚洲一区二区| 综合久久国产九一剧情麻豆| 成人午夜又粗又硬又大| 国产天堂亚洲国产碰碰| 国产成人超碰人人澡人人澡| 国产欧美精品区一区二区三区| 国产乱码字幕精品高清av | 国产乱码精品1区2区3区| 精品日产卡一卡二卡麻豆| 久久99久久99| 精品88久久久久88久久久| 久久丁香综合五月国产三级网站| 欧美一级淫片007| 精品一区二区精品| 久久日一线二线三线suv| 国产在线一区观看| 日本一二三四高清不卡| 99久久精品99国产精品| 国产精品二三区| 在线观看亚洲成人| 日韩二区三区在线观看| 精品理论电影在线| 粉嫩久久99精品久久久久久夜| 国产精品国产三级国产普通话蜜臀| proumb性欧美在线观看| 一区二区三区视频在线观看| 欧美三级在线看| 精品一区二区在线观看| 中文字幕乱码亚洲精品一区| 91在线看国产| 午夜私人影院久久久久| 精品久久免费看| 99精品国产热久久91蜜凸| 亚洲综合999| 日韩视频一区在线观看| 成人午夜免费电影| 亚洲午夜久久久久久久久电影院| 91精品麻豆日日躁夜夜躁| 久99久精品视频免费观看| 中文一区一区三区高中清不卡| 色香蕉成人二区免费| 美美哒免费高清在线观看视频一区二区 | 亚洲国产成人porn| 欧美mv日韩mv亚洲| 91丨porny丨蝌蚪视频| 午夜婷婷国产麻豆精品| 久久久国产午夜精品 | 久久综合网色—综合色88| 风间由美性色一区二区三区| 亚洲成人免费影院| 精品av久久707| 91久久精品一区二区三区| 美女在线观看视频一区二区| √…a在线天堂一区| 精品国产三级电影在线观看| 91影院在线观看| 狠狠色综合日日| 亚洲综合色噜噜狠狠| 久久先锋资源网| 欧美日韩国产一区| 成人h版在线观看| 精品一二三四在线| 亚洲宅男天堂在线观看无病毒| 国产午夜精品一区二区三区视频| 欧美中文字幕一二三区视频| 国产精品自在在线| 日韩av电影免费观看高清完整版 | 99久久精品免费| 精品一区二区三区不卡| 午夜免费久久看| 亚洲色图都市小说|