コード例 #1
0
 public MidiEventControlChange(int aDelta, byte aState, AByteArray aByteArray)
     : base(aDelta, aState, aByteArray.ReadByte(), aByteArray.ReadByte())
 {
     if (data1 == 0)
     {
         data = ( UInt16 )(data2 << 8);
     }
     else if (data1 == 32)
     {
         data |= ( UInt16 )data2;
     }
 }
コード例 #2
0
        public MidiEventKeyPressure(int aDelta, byte aState, AByteArray aByteArray)
            : base(aDelta, aState, 0, 0)
        {
            int length = aByteArray.ReadByte();

            aByteArray.AddPosition(length);
        }
コード例 #3
0
        public MetaEventPort(int aDelta, byte aType, AByteArray byteArray)
            : base(aDelta, aType)
        {
            int length = byteArray.ReadByte();

            byteArray.AddPosition(length);
        }
コード例 #4
0
        private void ReadChunk(AByteArray aByteArray)
        {
            string lId = aByteArray.ReadString(4);

            UInt32 lSize = aByteArray.ReadUInt32();

            int lPositionStart = aByteArray.Position;

            // Check Padding.
            if (lSize % 2 == 1)
            {
                if (lPositionStart + lSize <= aByteArray.Length && aByteArray.ReadByte(( int )(lPositionStart + lSize)) == 0x00)
                {
                    lSize++;

                    Logger.Debug("Padding:" + lSize);
                }
                else
                {
                    Logger.Debug("No Padding:" + lSize);
                }

                aByteArray.SetPosition(lPositionStart);
            }

            FormChunk lRiffWave = Construct(lId, lSize, aByteArray, this);

            chunkList.Add(lRiffWave);

            if (aByteArray.Position != lPositionStart + lSize)
            {
                Logger.Debug("Modify Position:" + aByteArray.Position + "->" + (lPositionStart + lSize));
                aByteArray.SetPosition(( int )(lPositionStart + lSize));
            }
        }
コード例 #5
0
        public KeySignature(int aDelta, byte aType, AByteArray byteArray)
            : base(aDelta, aType)
        {
            int length = byteArray.ReadByte();

            byteArray.AddPosition(length);
        }
コード例 #6
0
        public ShdrData(AByteArray aByteArray, List <string> aInformationList)
        {
            sampleName      = aByteArray.ReadString(20);
            start           = aByteArray.ReadUInt32();
            end             = aByteArray.ReadUInt32();
            startLoop       = aByteArray.ReadUInt32();
            endLoop         = aByteArray.ReadUInt32();
            sampleRate      = aByteArray.ReadUInt32();
            originalPitch   = aByteArray.ReadByte();
            pitchCorrection = aByteArray.ReadSByte();
            sampleLink      = aByteArray.ReadUInt16();
            sampleType      = ( SampleType )aByteArray.ReadUInt16();

            aInformationList.Add("Sample Name:" + sampleName);
            aInformationList.Add("Start:" + start);
            aInformationList.Add("End:" + end);
            aInformationList.Add("Start Loop:" + startLoop);
            aInformationList.Add("End Loop:" + endLoop);
            aInformationList.Add("Sample Rate:" + sampleRate);
            aInformationList.Add("Original Pitch:" + originalPitch);
            aInformationList.Add("Pitch Correction:" + pitchCorrection);
            aInformationList.Add("Sample Link:" + sampleLink);
            aInformationList.Add("Sample Type:" + sampleType);

            if (sampleType != SampleType.monoSample)
            {
                Logger.Warning(sampleName + "/" + "Not Mono Sample:" + sampleType);
            }
        }
コード例 #7
0
        // 可変長バイトを取得する.
        public static int GetVariableLengthByte(AByteArray aByteArray)
        {
            byte temp = aByteArray.ReadByte();

            int length = ( int )(temp & 0x7F);

            // 最上位ビットが1であれば読み込みを続ける.
            while ((temp & 0x80) == 0x80)
            {
                temp = aByteArray.ReadByte();

                length <<= 7;
                length  |= ( int )(temp & 0x7F);
            }

            return(length);
        }
コード例 #8
0
        public RiffWaveInst(string aId, UInt32 aSize, AByteArray aByteArray, RiffChunkList aParent)
            : base(aId, aSize, aByteArray, aParent)
        {
            unshiftedNote = aByteArray.ReadByte();
            fineTune      = aByteArray.ReadSByte();
            gain          = aByteArray.ReadSByte();
            lowNote       = aByteArray.ReadByte();
            highNote      = aByteArray.ReadByte();
            lowVelocity   = aByteArray.ReadByte();
            highVelocity  = aByteArray.ReadByte();

            informationList.Add("    Unshifted Note:" + unshiftedNote);
            informationList.Add("    Fine Tune:" + fineTune);
            informationList.Add("    Gain:" + gain);
            informationList.Add("    Low Note:" + lowNote);
            informationList.Add("    High Note:" + highNote);
            informationList.Add("    Low Velocity:" + lowVelocity);
            informationList.Add("    High Velocity:" + highVelocity);
        }
コード例 #9
0
        public MetaEventTempo(int aDelta, byte aType, AByteArray byteArray)
            : base(aDelta, aType)
        {
            int length = byteArray.ReadByte();

            if (length == 3)
            {
                byte data1 = byteArray.ReadByte();
                byte data2 = byteArray.ReadByte();
                byte data3 = byteArray.ReadByte();

                tempo = (( int )data1 << 16) | (( int )data2 << 8) | data3;
            }
            else
            {
                byteArray.AddPosition(3);
                Logger.Exception(new Exception());
            }
        }
コード例 #10
0
        public MidiEventSystemExclusive(int aDelta, byte aState, AByteArray aByteArray)
            : base(aDelta, aState, 0, 0)
        {
            length = MtrkChunk.GetVariableLengthByte(aByteArray);

            dataArray = new byte[length];

            for (int i = 0; i < length; i++)
            {
                dataArray[i] = aByteArray.ReadByte();
            }
        }
コード例 #11
0
        private Byte bb;                // 32分レベルビートサブディビジョンの状況、⇒4分音符1個の内部にある32分音符の個数

        public MetaEventTimeSignature(int aDelta, Byte aType, AByteArray byteArray)
            : base(aDelta, aType)
        {
            int length = byteArray.ReadByte();

            if (length == 4)
            {
                nn = byteArray.ReadByte();
                Byte shift = byteArray.ReadByte();
                cc = byteArray.ReadByte();
                bb = byteArray.ReadByte();

                for (int i = 0; i < shift; i++)
                {
                    dd *= 2;
                }
            }
            else
            {
                byteArray.AddPosition(3);
                Logger.Exception(new Exception());
            }
        }
コード例 #12
0
        // トラックのイベントを読み込む.
        private void ReadTrack(AByteArray aByteArray)
        {
            int  lDelta    = 0;
            byte lStatePre = 0;

            int lPositionPre = aByteArray.Position;

            // トラック終了まで読み込む.
            while (aByteArray.Position < lPositionPre + size)
            {
                lDelta += GetVariableLengthByte(aByteArray);

                byte lState = aByteArray.ReadByte();

                // ランニングステータス対応.
                if (lState < 0x80)
                {
                    lState = lStatePre;
                    aByteArray.SubPosition(1);
                }

                lStatePre = lState;

                if (lState != 0xFF)
                {
                    // MIDIイベント読み込み.
                    MidiEventBase lMidiEvent = MidiEventReader.Execute(lDelta, lState, aByteArray);

                    midiEventList.Add(lMidiEvent);
                }
                else
                {
                    // メタイベント読み込み.
                    MetaEventBase lMetaEvent = MetaEventReader.Execute(lDelta, aByteArray);

                    metaEventList.Add(lMetaEvent);
                }
            }
        }
コード例 #13
0
 public MidiEventProgramChange(int aDelta, byte aState, AByteArray aByteArray)
     : base(aDelta, aState, aByteArray.ReadByte(), 0)
 {
 }
コード例 #14
0
        public static MetaEventBase Execute(int aDelta, AByteArray aByteArray)
        {
            MetaEventBase lMetaEvent;
            byte          lType = aByteArray.ReadByte();

            switch (lType)
            {
            case 0x01:                  // Text.
                lMetaEvent = new MetaEventText(aDelta, lType, aByteArray);
                break;

            case 0x02:                  // Copyright Notice.
                lMetaEvent = new MetaEventText(aDelta, lType, aByteArray);
                break;

            case 0x03:                  // Sequense/Track Name.
                lMetaEvent = new MetaEventText(aDelta, lType, aByteArray);
                break;

            case 0x04:                  // Instrument Name.
                lMetaEvent = new MetaEventText(aDelta, lType, aByteArray);
                break;

            case 0x05:                  // Lylics.
                lMetaEvent = new MetaEventText(aDelta, lType, aByteArray);
                break;

            case 0x06:                  // Marker.
                lMetaEvent = new MetaEventText(aDelta, lType, aByteArray);
                break;

            case 0x07:                  // Queue Point.
                lMetaEvent = new MetaEventText(aDelta, lType, aByteArray);
                break;

            case 0x20:
                lMetaEvent = new MetaEventChannel(aDelta, lType, aByteArray);
                break;

            case 0x21:
                lMetaEvent = new MetaEventPort(aDelta, lType, aByteArray);
                break;

            case 0x2F:
                lMetaEvent = new MetaEventTrackEnd(aDelta, lType, aByteArray);
                break;

            case 0x51:
                lMetaEvent = new MetaEventTempo(aDelta, lType, aByteArray);
                break;

            case 0x54:
                lMetaEvent = new MetaEventSmpteOffset(aDelta, lType, aByteArray);
                break;

            case 0x58:
                lMetaEvent = new MetaEventTimeSignature(aDelta, lType, aByteArray);
                break;

            case 0x59:
                lMetaEvent = new KeySignature(aDelta, lType, aByteArray);
                break;

            case 0x7F:                  // Sequencer Meta Event.
                lMetaEvent = new MetaEventText(aDelta, lType, aByteArray);
                break;

            default:
                // �����`�̃��^�C�x���g���b�Z�[�W.
                Logger.Error("Undefined Meta Event");
                throw new Exception();
            }

            return(lMetaEvent);
        }
コード例 #15
0
ファイル: SfbkData.cs プロジェクト: activerecords/loop-tool
 public Generator(AByteArray aByteArray)
 {
     byte1 = aByteArray.ReadByte();
     byte2 = aByteArray.ReadByte();
 }
コード例 #16
0
 public MidiEventPitchWheelChange(int aDelta, byte aState, AByteArray aByteArray)
     : base(aDelta, aState, aByteArray.ReadByte(), aByteArray.ReadByte())
 {
 }
コード例 #17
0
 public MidiEventNoteOn(int aDelta, byte aState, AByteArray aByteArray)
     : base(aDelta, aState, aByteArray.ReadByte(), aByteArray.ReadByte())
 {
 }
コード例 #18
0
 public MidiEventChannelPressure(int aDelta, byte aState, AByteArray aByteArray)
     : base(aDelta, aState, aByteArray.ReadByte(), 0)
 {
 }