|
-
Senior Member
What experience do you have with AS3? You'll need to learn the basics first.
If your familiar to programming you may look up y, sprite, ENTER_FRAME and classes.
-
I'm studying it to be honest(multimedia in Belgium). So I can work with as3, i got the hang of the basics, but I'm not a professional ^^
The thing I'm looking for is how I can assign each movieclip to each note in that midi file.
EDIT: Would it be easier if I made an XML file of it first ?
Last edited by FlashyMapper; 06-14-2012 at 04:20 PM.
-
I want to be able to dynamically create movieclips in flash based on a midi file.
So I converted the midi file to an .xml file first. I traced the number of events going on and the time of when an event starts or ends.
So to keep track of those times, I put them in an array.(keytimer[i])
The timer goes up 1microsecond at a time, for as long as the song is; in this case 190080 microseconds.
The thing I want is when the timer equals a number in this array(keytimer[i]), and only when the attribute is 'NoteOn', then it should create a movieclip.
I tried doing it like this; but he doesnt recognise the array:
Code:
if (current==keytimer[i]) {
trace("yes");
}
Actionscript Code:
var xmlLoader:URLLoader = new URLLoader(); xmlLoader.addEventListener(Event.COMPLETE, showXML); xmlLoader.load(new URLRequest("for_elise_by_beethoven.xml")); function showXML(e:Event):void { XML.ignoreWhitespace=true; var songs:XML=new XML(e.target.data); trace(songs.Track.Event.length()); var i:Number; var keytimer:Array = new Array(); for (i=0; i < songs.Track.Event.length(); i++) { keytimer[i] =(" Time of the key: "+ songs.Track.Event[i].Absolute.text()); if (current==keytimer[i]) { trace("yes"); } //trace(keytimer[i]); //trace(" NoteOn: "+ songs.Track.Event[i].NoteOn.@Note); //trace(" NoteOff: "+ songs.Track.Event[i].NoteOff.@Note); //trace(" "); } var myTimer:Timer=new Timer(1,190000); myTimer.addEventListener(TimerEvent.TIMER,doStuff); var current:Number=0; myTimer.start(); function doStuff(event:TimerEvent):void { current++; trace("current: "+ current); trace("keytimer: "+ keytimer[i]); //trace("keytimer: "+ keytimer[i]); /*if (current==keytimer[i]) { trace("yes"); }*/
} }
The current xml file: (name: for_elise_by_beethoven.xml)
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE MIDIFile PUBLIC
"-//Recordare//DTD MusicXML 0.9 MIDI//EN"
"http://www.musicxml.org/dtds/midixml.dtd">
<MIDIFile>
<Format>1</Format>
<TrackCount>4</TrackCount>
<TicksPerBeat>960</TicksPerBeat>
<TimestampType>Absolute</TimestampType>
<Track Number="0">
<Event>
<Absolute>0</Absolute>
<SequencerSpecific>05 0f 12 00 00 7f 7f 00</SequencerSpecific>
</Event>
<Event>
<Absolute>0</Absolute>
<SequencerSpecific>05 0f 1c 32 30 30 35 2e 31 32 2e 30 32</SequencerSpecific>
</Event>
<Event>
<Absolute>0</Absolute>
<TrackName>Track 0</TrackName>
</Event>
<Event>
<Absolute>0</Absolute>
<SetTempo Value="857143"/>
</Event>
<Event>
<Absolute>0</Absolute>
<EndOfTrack/>
</Event>
</Track>
<Track Number="1">
<Event>
<Absolute>0</Absolute>
<ProgramChange Channel="1" Number="0"/>
</Event>
<Event>
<Absolute>0</Absolute>
<SequencerSpecific>05 0f 09 40 48</SequencerSpecific>
</Event>
<Event>
<Absolute>0</Absolute>
<CopyrightNotice>2006 by forelise.com</CopyrightNotice>
</Event>
<Event>
<Absolute>0</Absolute>
<InstrumentName>Piano</InstrumentName>
</Event>
<Event>
<Absolute>0</Absolute>
<TrackName>Für Elise</TrackName>
</Event>
<Event>
<Absolute>0</Absolute>
<SequencerSpecific>05 0f 06 47 65 6e 65 72 61 6c 20 4d 49 44 49</SequencerSpecific>
</Event>
<Event>
<Absolute>0</Absolute>
<TimeSignature Numerator="3" LogDenominator="3" MIDIClocksPerMetronomeClick="12" ThirtySecondsPer24Clocks="8"/>
</Event>
<Event>
<Absolute>0</Absolute>
<MIDIChannelPrefix Value="00"/>
</Event>
<Event>
<Absolute>960</Absolute>
<NoteOn Channel="1" Note="76" Velocity="71"/>
</Event>
<Event>
<Absolute>1200</Absolute>
<NoteOff Channel="1" Note="76" Velocity="0"/>
</Event>
<Event>
<Absolute>1200</Absolute>
<NoteOn Channel="1" Note="75" Velocity="38"/>
</Event>
<Event>
<Absolute>1440</Absolute>
<NoteOff Channel="1" Note="75" Velocity="0"/>
</Event>
<Event>
<Absolute>1440</Absolute>
<NoteOn Channel="1" Note="76" Velocity="57"/>
</Event>
<Event>
<Absolute>1680</Absolute>
<NoteOff Channel="1" Note="76" Velocity="0"/>
</Event>
<Event>
<Absolute>1680</Absolute>
<NoteOn Channel="1" Note="75" Velocity="70"/>
</Event>
<Event>
<Absolute>1920</Absolute>
<NoteOff Channel="1" Note="75" Velocity="0"/>
</Event>
etc....
<Event>
<Absolute>187200</Absolute>
<NoteOff Channel="1" Note="45" Velocity="0"/>
</Event>
<Event>
<Absolute>187200</Absolute>
<NoteOff Channel="1" Note="33" Velocity="0"/>
</Event>
<Event>
<Absolute>187200</Absolute>
<NoteOff Channel="1" Note="60" Velocity="0"/>
</Event>
<Event>
<Absolute>187200</Absolute>
<NoteOff Channel="1" Note="69" Velocity="0"/>
</Event>
<Event>
<Absolute>190048</Absolute>
<ControlChange Channel="1" Control="64" Value="0"/>
</Event>
<Event>
<Absolute>190080</Absolute>
<SequencerSpecific>05 0f 0a</SequencerSpecific>
</Event>
<Event>
<Absolute>190080</Absolute>
<EndOfTrack/>
</Event>
</Track>
<Track Number="2">
<Event>
<Absolute>0</Absolute>
<SequencerSpecific>05 0f 09 00 40</SequencerSpecific>
</Event>
<Event>
<Absolute>0</Absolute>
<SequencerSpecific>05 0f 06 47 65 6e 65 72 61 6c 20 4d 49 44 49</SequencerSpecific>
</Event>
<Event>
<Absolute>0</Absolute>
<TrackName>http://www.forelise.com/</TrackName>
</Event>
<Event>
<Absolute>0</Absolute>
<TimeSignature Numerator="3" LogDenominator="3" MIDIClocksPerMetronomeClick="12" ThirtySecondsPer24Clocks="8"/>
</Event>
<Event>
<Absolute>0</Absolute>
<ProgramChange Channel="2" Number="0"/>
</Event>
<Event>
<Absolute>0</Absolute>
<MIDIChannelPrefix Value="01"/>
</Event>
<Event>
<Absolute>0</Absolute>
<EndOfTrack/>
</Event>
</Track>
<Track Number="3">
<Event>
<Absolute>0</Absolute>
<SequencerSpecific>05 0f 09 00 40</SequencerSpecific>
</Event>
<Event>
<Absolute>0</Absolute>
<SequencerSpecific>05 0f 06 47 65 6e 65 72 61 6c 20 4d 49 44 49</SequencerSpecific>
</Event>
<Event>
<Absolute>0</Absolute>
<TrackName>Composed by Ludwig van Beethoven</TrackName>
</Event>
<Event>
<Absolute>0</Absolute>
<TimeSignature Numerator="3" LogDenominator="3" MIDIClocksPerMetronomeClick="12" ThirtySecondsPer24Clocks="8"/>
</Event>
<Event>
<Absolute>0</Absolute>
<ProgramChange Channel="3" Number="0"/>
</Event>
<Event>
<Absolute>0</Absolute>
<MIDIChannelPrefix Value="02"/>
</Event>
<Event>
<Absolute>0</Absolute>
<EndOfTrack/>
</Event>
</Track>
</MIDIFile>
Last edited by FlashyMapper; 06-14-2012 at 04:20 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|