/// <inheritdoc />
        public void FinishTrack(int track, int tick)
        {
            var message = new MetaDataEvent(tick,
                                            0xFF,
                                            (byte)MetaEventTypeEnum.EndOfTrack,
                                            new byte[0]);

            _midiFile.AddEvent(message);
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        void IMetaDataListener.OnMetaDataEvent(MetaData metaData, MetaDataEvent evt)
        {
            switch (evt)
            {
            case MetaDataEvent.BeginCreateTables:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginCreateTables);
                break;

            case MetaDataEvent.MemberDefRidsAllocated:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefRidsAllocated);
                break;

            case MetaDataEvent.MemberDefsInitialized:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefsInitialized);
                break;

            case MetaDataEvent.MostTablesSorted:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDMostTablesSorted);
                break;

            case MetaDataEvent.MemberDefCustomAttributesWritten:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefCustomAttributesWritten);
                break;

            case MetaDataEvent.BeginAddResources:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginAddResources);
                break;

            case MetaDataEvent.EndAddResources:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndAddResources);
                break;

            case MetaDataEvent.BeginWriteMethodBodies:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginWriteMethodBodies);
                break;

            case MetaDataEvent.EndWriteMethodBodies:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndWriteMethodBodies);
                break;

            case MetaDataEvent.OnAllTablesSorted:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDOnAllTablesSorted);
                break;

            case MetaDataEvent.EndCreateTables:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndCreateTables);
                break;

            default:
                break;
            }
        }
        /// <inheritdoc />
        public void AddTimeSignature(int tick, int timeSignatureNumerator, int timeSignatureDenominator)
        {
            var denominatorIndex = 0;

            while ((timeSignatureDenominator = (timeSignatureDenominator >> 1)) > 0)
            {
                denominatorIndex++;
            }

            var message = new MetaDataEvent(tick,
                                            0xFF,
                                            (byte)MetaEventTypeEnum.TimeSignature,
                                            new byte[] { (byte)(timeSignatureNumerator & 0xFF), (byte)(denominatorIndex & 0xFF), 48, 8 });

            _midiFile.AddEvent(message);
        }
Ejemplo n.º 4
0
        internal static MidiFile JsObjectToMidiFile(dynamic midi)
        {
            var midi2 = new MidiFile();

            midi2.Division = midi.Division;

            FastList <dynamic> midiEvents = midi.Events;

            foreach (var midiEvent in midiEvents)
            {
                int       tick    = midiEvent.Tick;
                int       message = midiEvent.Message;
                MidiEvent midiEvent2;
                switch (midiEvent.Type)
                {
                case "alphaTab.audio.synth.midi.event.SystemExclusiveEvent":
                    midiEvent2         = new SystemExclusiveEvent(tick, 0, 0, midiEvent.Data);
                    midiEvent2.Message = message;
                    break;

                case "alphaTab.audio.synth.midi.event.MetaDataEvent":
                    midiEvent2         = new MetaDataEvent(tick, 0, 0, midiEvent.Data);
                    midiEvent2.Message = message;
                    break;

                case "alphaTab.audio.synth.midi.event.MetaNumberEvent":
                    midiEvent2         = new MetaNumberEvent(tick, 0, 0, midiEvent.Value);
                    midiEvent2.Message = message;
                    break;

                default:
                    midiEvent2         = new MidiEvent(tick, 0, 0, 0);
                    midiEvent2.Message = message;
                    break;
                }
                midi2.Events.Add(midiEvent2);
            }

            return(midi2);
        }
Ejemplo n.º 5
0
        internal static object MidiFileToJsObject(MidiFile midi)
        {
            var midi2 = Platform.Platform.NewObject();

            midi2.Division = midi.Division;
            var midiEvents = new FastList <object>();

            midi2.Events = midiEvents;
            foreach (var midiEvent in midi.Events)
            {
                var midiEvent2 = Platform.Platform.NewObject();
                midiEvents.Add(midiEvent2);
                midiEvent2.Type    = Platform.Platform.GetTypeName(midiEvent);
                midiEvent2.Tick    = midiEvent.Tick;
                midiEvent2.Message = midiEvent.Message;
                switch (midiEvent2.Type)
                {
                case "alphaTab.audio.synth.midi.event.SystemExclusiveEvent":
                    SystemExclusiveEvent sysex = (SystemExclusiveEvent)midiEvent;
                    midiEvent2.Data = sysex.Data;
                    break;

                case "alphaTab.audio.synth.midi.event.MetaDataEvent":
                    MetaDataEvent metadata = (MetaDataEvent)midiEvent;
                    midiEvent2.Data = metadata.Data;
                    break;

                case "alphaTab.audio.synth.midi.event.MetaNumberEvent":
                    MetaNumberEvent metanumber = (MetaNumberEvent)midiEvent;
                    midiEvent2.Value = metanumber.Value;
                    break;
                }
            }

            return(midi2);
        }
		/// <inheritdoc/>
		void IMetaDataListener.OnMetaDataEvent(MetaData metaData, MetaDataEvent evt) {
			switch (evt) {
			case MetaDataEvent.BeginCreateTables:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginCreateTables);
				break;

			case MetaDataEvent.MemberDefRidsAllocated:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefRidsAllocated);
				break;

			case MetaDataEvent.MemberDefsInitialized:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefsInitialized);
				break;

			case MetaDataEvent.MostTablesSorted:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDMostTablesSorted);
				break;

			case MetaDataEvent.MemberDefCustomAttributesWritten:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefCustomAttributesWritten);
				break;

			case MetaDataEvent.BeginWriteMethodBodies:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginWriteMethodBodies);
				break;

			case MetaDataEvent.EndWriteMethodBodies:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndWriteMethodBodies);
				break;

			case MetaDataEvent.BeginAddResources:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginAddResources);
				break;

			case MetaDataEvent.EndAddResources:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndAddResources);
				break;

			case MetaDataEvent.OnAllTablesSorted:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDOnAllTablesSorted);
				break;

			case MetaDataEvent.EndCreateTables:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndCreateTables);
				break;

			default:
				break;
			}
		}
Ejemplo n.º 7
0
		/// <inheritdoc/>
		public void OnMetaDataEvent(MetaData metaData, MetaDataEvent evt) {
		}
Ejemplo n.º 8
0
		/// <inheritdoc/>
		void IMetaDataListener.OnMetaDataEvent(MetaData metaData, MetaDataEvent evt) {
			switch (evt) {
			case MetaDataEvent.BeginCreateTables:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginCreateTables);
				break;

			case MetaDataEvent.AllocateTypeDefRids:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateTypeDefRids);
				break;

			case MetaDataEvent.AllocateMemberDefRids:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids);
				break;

			case MetaDataEvent.AllocateMemberDefRids0:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids0);
				break;

			case MetaDataEvent.AllocateMemberDefRids1:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids1);
				break;

			case MetaDataEvent.AllocateMemberDefRids2:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids2);
				break;

			case MetaDataEvent.AllocateMemberDefRids3:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids3);
				break;

			case MetaDataEvent.AllocateMemberDefRids4:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids4);
				break;

			case MetaDataEvent.MemberDefRidsAllocated:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefRidsAllocated);
				break;

			case MetaDataEvent.InitializeTypeDefsAndMemberDefs0:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDInitializeTypeDefsAndMemberDefs0);
				break;

			case MetaDataEvent.InitializeTypeDefsAndMemberDefs1:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDInitializeTypeDefsAndMemberDefs1);
				break;

			case MetaDataEvent.InitializeTypeDefsAndMemberDefs2:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDInitializeTypeDefsAndMemberDefs2);
				break;

			case MetaDataEvent.InitializeTypeDefsAndMemberDefs3:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDInitializeTypeDefsAndMemberDefs3);
				break;

			case MetaDataEvent.InitializeTypeDefsAndMemberDefs4:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDInitializeTypeDefsAndMemberDefs4);
				break;

			case MetaDataEvent.MemberDefsInitialized:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefsInitialized);
				break;

			case MetaDataEvent.BeforeSortTables:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeforeSortTables);
				break;

			case MetaDataEvent.MostTablesSorted:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDMostTablesSorted);
				break;

			case MetaDataEvent.WriteTypeDefAndMemberDefCustomAttributes0:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteTypeDefAndMemberDefCustomAttributes0);
				break;

			case MetaDataEvent.WriteTypeDefAndMemberDefCustomAttributes1:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteTypeDefAndMemberDefCustomAttributes1);
				break;

			case MetaDataEvent.WriteTypeDefAndMemberDefCustomAttributes2:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteTypeDefAndMemberDefCustomAttributes2);
				break;

			case MetaDataEvent.WriteTypeDefAndMemberDefCustomAttributes3:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteTypeDefAndMemberDefCustomAttributes3);
				break;

			case MetaDataEvent.WriteTypeDefAndMemberDefCustomAttributes4:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteTypeDefAndMemberDefCustomAttributes4);
				break;

			case MetaDataEvent.MemberDefCustomAttributesWritten:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefCustomAttributesWritten);
				break;

			case MetaDataEvent.BeginAddResources:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginAddResources);
				break;

			case MetaDataEvent.EndAddResources:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndAddResources);
				break;

			case MetaDataEvent.BeginWriteMethodBodies:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginWriteMethodBodies);
				break;

			case MetaDataEvent.WriteMethodBodies0:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies0);
				break;

			case MetaDataEvent.WriteMethodBodies1:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies1);
				break;

			case MetaDataEvent.WriteMethodBodies2:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies2);
				break;

			case MetaDataEvent.WriteMethodBodies3:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies3);
				break;

			case MetaDataEvent.WriteMethodBodies4:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies4);
				break;

			case MetaDataEvent.WriteMethodBodies5:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies5);
				break;

			case MetaDataEvent.WriteMethodBodies6:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies6);
				break;

			case MetaDataEvent.WriteMethodBodies7:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies7);
				break;

			case MetaDataEvent.WriteMethodBodies8:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies8);
				break;

			case MetaDataEvent.WriteMethodBodies9:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies9);
				break;

			case MetaDataEvent.EndWriteMethodBodies:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndWriteMethodBodies);
				break;

			case MetaDataEvent.OnAllTablesSorted:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDOnAllTablesSorted);
				break;

			case MetaDataEvent.EndCreateTables:
				Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndCreateTables);
				break;

			default:
				break;
			}
		}
Ejemplo n.º 9
0
        /// <inheritdoc/>
        void IMetaDataListener.OnMetaDataEvent(MetaData metaData, MetaDataEvent evt)
        {
            switch (evt)
            {
            case MetaDataEvent.BeginCreateTables:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginCreateTables);
                break;

            case MetaDataEvent.AllocateTypeDefRids:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateTypeDefRids);
                break;

            case MetaDataEvent.AllocateMemberDefRids:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids);
                break;

            case MetaDataEvent.AllocateMemberDefRids0:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids0);
                break;

            case MetaDataEvent.AllocateMemberDefRids1:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids1);
                break;

            case MetaDataEvent.AllocateMemberDefRids2:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids2);
                break;

            case MetaDataEvent.AllocateMemberDefRids3:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids3);
                break;

            case MetaDataEvent.AllocateMemberDefRids4:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDAllocateMemberDefRids4);
                break;

            case MetaDataEvent.MemberDefRidsAllocated:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefRidsAllocated);
                break;

            case MetaDataEvent.InitializeTypeDefsAndMemberDefs0:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDInitializeTypeDefsAndMemberDefs0);
                break;

            case MetaDataEvent.InitializeTypeDefsAndMemberDefs1:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDInitializeTypeDefsAndMemberDefs1);
                break;

            case MetaDataEvent.InitializeTypeDefsAndMemberDefs2:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDInitializeTypeDefsAndMemberDefs2);
                break;

            case MetaDataEvent.InitializeTypeDefsAndMemberDefs3:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDInitializeTypeDefsAndMemberDefs3);
                break;

            case MetaDataEvent.InitializeTypeDefsAndMemberDefs4:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDInitializeTypeDefsAndMemberDefs4);
                break;

            case MetaDataEvent.MemberDefsInitialized:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefsInitialized);
                break;

            case MetaDataEvent.BeforeSortTables:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeforeSortTables);
                break;

            case MetaDataEvent.MostTablesSorted:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDMostTablesSorted);
                break;

            case MetaDataEvent.WriteTypeDefAndMemberDefCustomAttributes0:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteTypeDefAndMemberDefCustomAttributes0);
                break;

            case MetaDataEvent.WriteTypeDefAndMemberDefCustomAttributes1:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteTypeDefAndMemberDefCustomAttributes1);
                break;

            case MetaDataEvent.WriteTypeDefAndMemberDefCustomAttributes2:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteTypeDefAndMemberDefCustomAttributes2);
                break;

            case MetaDataEvent.WriteTypeDefAndMemberDefCustomAttributes3:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteTypeDefAndMemberDefCustomAttributes3);
                break;

            case MetaDataEvent.WriteTypeDefAndMemberDefCustomAttributes4:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteTypeDefAndMemberDefCustomAttributes4);
                break;

            case MetaDataEvent.MemberDefCustomAttributesWritten:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDMemberDefCustomAttributesWritten);
                break;

            case MetaDataEvent.BeginAddResources:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginAddResources);
                break;

            case MetaDataEvent.EndAddResources:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndAddResources);
                break;

            case MetaDataEvent.BeginWriteMethodBodies:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDBeginWriteMethodBodies);
                break;

            case MetaDataEvent.WriteMethodBodies0:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies0);
                break;

            case MetaDataEvent.WriteMethodBodies1:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies1);
                break;

            case MetaDataEvent.WriteMethodBodies2:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies2);
                break;

            case MetaDataEvent.WriteMethodBodies3:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies3);
                break;

            case MetaDataEvent.WriteMethodBodies4:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies4);
                break;

            case MetaDataEvent.WriteMethodBodies5:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies5);
                break;

            case MetaDataEvent.WriteMethodBodies6:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies6);
                break;

            case MetaDataEvent.WriteMethodBodies7:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies7);
                break;

            case MetaDataEvent.WriteMethodBodies8:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies8);
                break;

            case MetaDataEvent.WriteMethodBodies9:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDWriteMethodBodies9);
                break;

            case MetaDataEvent.EndWriteMethodBodies:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndWriteMethodBodies);
                break;

            case MetaDataEvent.OnAllTablesSorted:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDOnAllTablesSorted);
                break;

            case MetaDataEvent.EndCreateTables:
                Listener.OnWriterEvent(this, ModuleWriterEvent.MDEndCreateTables);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 10
0
 /// <inheritdoc/>
 public void OnMetaDataEvent(MetaData metaData, MetaDataEvent evt)
 {
 }