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

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

?? midinote.cpp

?? s3c2440 WINCE 5.00 官方bsp
?? 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一区二区三区免费野_久草精品视频
国产乱淫av一区二区三区| 8x8x8国产精品| 国产91综合一区在线观看| 麻豆专区一区二区三区四区五区| 亚洲在线中文字幕| 亚洲高清在线精品| 亚洲尤物视频在线| 午夜视频在线观看一区二区| 亚洲动漫第一页| 日韩精品色哟哟| 美女网站一区二区| 蓝色福利精品导航| 国产福利精品一区| av网站免费线看精品| 99精品欧美一区二区三区小说 | 日本一区二区三区免费乱视频| 亚洲精品一区二区三区影院 | 日韩成人午夜精品| 免费一区二区视频| 国产伦精品一区二区三区视频青涩| 欧美日韩在线播| 国产成人精品亚洲午夜麻豆| 亚洲国产中文字幕在线视频综合 | 国产成人精品免费一区二区| 日本vs亚洲vs韩国一区三区二区 | 国产精品黄色在线观看| 欧美大片一区二区三区| 欧美福利电影网| 欧美日韩精品一区二区| 91激情在线视频| 在线亚洲免费视频| 欧美另类一区二区三区| 5858s免费视频成人| 欧美精品在线观看一区二区| 91麻豆产精品久久久久久| 69久久夜色精品国产69蝌蚪网| 欧美日韩精品综合在线| 国产在线不卡一卡二卡三卡四卡| 亚洲国产精品欧美一二99| 美脚の诱脚舐め脚责91| 六月丁香婷婷色狠狠久久| 久久99精品久久久久久动态图| 久久精品国产99| 国产成人精品影视| 97精品视频在线观看自产线路二| 国产午夜久久久久| 在线免费观看一区| 一区二区三区视频在线看| 视频一区国产视频| 国产成人综合在线观看| 亚洲午夜激情网站| 国精产品一区一区三区mba桃花| 国产精品99久久久久久久女警 | 毛片av中文字幕一区二区| 亚洲欧美色一区| 久久99久久99| 一本大道久久a久久精二百| 91精品婷婷国产综合久久性色| 国产精品久久久一区麻豆最新章节| 亚洲美女视频在线| 韩国毛片一区二区三区| 欧美日韩一二三区| 国产欧美一区二区三区沐欲| 丝袜美腿高跟呻吟高潮一区| 成人国产精品免费观看视频| 欧美一级二级三级蜜桃| 亚洲三级在线免费观看| 麻豆成人91精品二区三区| 91污片在线观看| 国产婷婷色一区二区三区四区 | 99精品视频在线免费观看| 日韩美女视频一区二区在线观看| 亚洲免费毛片网站| 国产成人午夜99999| 精品噜噜噜噜久久久久久久久试看 | 亚洲男人的天堂在线aⅴ视频| 国内精品伊人久久久久av影院| 欧美色图片你懂的| 亚洲欧美国产三级| 成人免费福利片| 久久久亚洲精品一区二区三区| 日韩中文字幕区一区有砖一区| 在线亚洲一区二区| 亚洲视频一区二区免费在线观看| 国产乱码精品一区二区三区忘忧草 | 亚洲视频免费在线观看| 高清国产一区二区三区| 久久久www成人免费毛片麻豆| 日韩国产精品久久久久久亚洲| 欧美日韩国产另类不卡| 午夜欧美视频在线观看| 欧美一区二区三区男人的天堂| 亚洲一区二区三区自拍| 欧美精品乱码久久久久久按摩| 日韩精品电影在线观看| 欧美一区二区三区免费观看视频| 天堂精品中文字幕在线| 日韩欧美的一区| 国产成人在线看| 亚洲精品高清视频在线观看| 99久久精品免费看国产免费软件| 亚洲高清免费一级二级三级| 欧美一区二区网站| 欧美另类高清zo欧美| 欧美96一区二区免费视频| 99re亚洲国产精品| 亚洲6080在线| 国产欧美日韩激情| 欧美日韩中字一区| 国产精品2024| 亚洲国产视频网站| 亚洲欧美日韩久久精品| 在线免费av一区| 成人午夜免费电影| 欧美精品丝袜中出| 日韩欧美的一区二区| 久久精品人人做人人爽人人| 国产精品一区不卡| 国产精品乱人伦| 日本福利一区二区| 亚洲欧美日韩成人高清在线一区| 欧美一二三区在线观看| av在线一区二区三区| 精品写真视频在线观看| 精品一区二区三区日韩| 91丝袜呻吟高潮美腿白嫩在线观看| 日韩美一区二区三区| 99久久精品情趣| 亚洲综合激情网| 在线91免费看| 国产一区二区视频在线| 国产精品久久久久久久久免费相片 | 久久综合五月天婷婷伊人| 国产98色在线|日韩| 亚洲精品久久久蜜桃| 欧美日本在线播放| 国产一区不卡精品| 亚洲日本在线观看| 制服丝袜一区二区三区| 国产麻豆精品theporn| 亚洲三级免费观看| 91麻豆精品国产91久久久更新时间 | 午夜欧美一区二区三区在线播放| 日韩丝袜情趣美女图片| 不卡在线观看av| 石原莉奈在线亚洲二区| 久久久久久免费网| 欧美日韩精品免费| 国产成人亚洲综合a∨婷婷| 亚洲香蕉伊在人在线观| 久久女同互慰一区二区三区| 91久久奴性调教| 国产一区二区三区精品视频 | 99久久综合精品| 日本伊人精品一区二区三区观看方式| 久久这里只有精品6| 日本精品免费观看高清观看| 蜜桃久久久久久| 亚洲精品视频免费观看| 欧美成人乱码一区二区三区| 色综合中文字幕| 国产精品一区二区三区乱码| 亚洲综合成人在线视频| 欧美一区二区日韩| 国产精品女人毛片| 亚洲素人一区二区| 捆绑紧缚一区二区三区视频| 国产伦精品一区二区三区在线观看| 成人午夜电影小说| 精品福利一区二区三区免费视频| 久久精品水蜜桃av综合天堂| 亚洲人成精品久久久久| 精品一区免费av| 91精品1区2区| 中文成人综合网| 蜜臀av性久久久久蜜臀aⅴ| 99久久综合狠狠综合久久| 欧美日韩免费一区二区三区视频| 久久综合九色综合97_久久久| 一区二区欧美精品| 国产一区二区三区久久悠悠色av| 欧美午夜寂寞影院| 久久精品在这里| 狠狠色丁香久久婷婷综| 日韩精品中午字幕| 久久激情五月激情| 亚洲久草在线视频| 欧美日韩国产在线播放网站| 精品久久久久一区| 亚洲精品高清视频在线观看| 国产1区2区3区精品美女| 日韩三级av在线播放| 亚洲成a人片在线观看中文| 99国产精品国产精品毛片| 国产喂奶挤奶一区二区三区| 精品一区二区免费视频| 欧美一区二区在线播放| 亚洲一区二区成人在线观看| 欧美视频在线一区二区三区| 不卡的av中国片|