Need a library that can detect “Musical Time” Intelligent Music System for everyone.
What is MusicEngine A single MonoBehaviour script. Music.cs Things you can do easily access to What bar/beat/unit is it now? easily animate With Synced to Music. Things you can NOT do animate with synced to audio data: use GetSpectrumData instead. change music dynamically: use ADX2LE/WWise instead.
Premise Make music for your own. • MusicEngine can’t auto detect your music tempo/meters. You always have ONE Music. • You can always access to musical info from Music.something(static members) 1MusicalTime=sixteenth note(note) • Music.MusicalTime increases 1 per 1 sixteenth note. • (note)You can modify this unit depends on musics or sections.
5 steps to get things done. Step1. Add Music component Step2. Quantize sound Step3. Fit int the beat Step4. Animate along the beat Step5. Scene transition with the music
Step1. Add Music component Drag Music.cs to a gameobject default section info will be added (tempo=120, 4/4) You are ready to access Music.Just from your code. Note: If you music doesn’t starts from 0 sample, please specify the EntryPointSample. StartTimeSamples (inside the section info) will be automatically calcurated from Start Timing.
Tips1: Timing & Section class Timing • int Bar; • int Beat; • int Unit; //sixteenth note Note: Starts from (0,0,0). Last timing of 4 bar, 4/4 section will be (3,3,3). class Music.Section • int UnitPerBeat=4; //how many unit per beat • int UnitPerBar=16;//how many unit per bar • int Tempo=120; //beat per minutes • Timing StartTiming; //section’s start timing Note: If you want to use 7/8, try UnitPerBeat=4 & UnitPerBar=14.
Ready SYSTEM ALL GREEN
Tips2: DebugText Attach 3DText(TextMesh) to DebugText→ Current Timing(0Bar, 3Beat, 3Unit) Musical Time(16=1bar) Current section. ”Start” section starts from (0,0,0), tempo = 128. Note: You can suspend/resume or change pitch of music. It’s no probrem for timing mesuring.
Step2. Quantize sound Music.QuantizePlay(AudioSource source, int transpose); • Audio will be quantized to musical time. • “transpose” argument: 1 = half tone , 12 = octave. Ex. Ball.cs↓ Quantizing the reflect sounds.
Quantize + transpose. Simply fun. GOOD COST PERFORMANCE!
Step3. Fit in the beat bool Music.IsJustChangedBar()/Beat()/At(Timing) Turns true on every ONE FRAME the bar/beat/timing changes. Ex. Field.cs↓ Changing backgroundColor
Music synced events. BACK COLOR CHANGE LOOKS COOL.
Tips3: Just & Near Timing Music.Just : changes JUST after the beat. Timing Music.Near : indicates the NEARest beat. Note: If the tempo=120 and you have 60 frame per sec, 1 MusicalTime has 7.5 frames in average. Note: If you want to do something just BEFORE the timing, IsNearChanged event would be useful.
Step4. Animate along the beat MUSIC SYNCED ANIMATION
Step4-1.Blink animation bool Music.IsFormerHalf blink true/false in forer/later of a musical time. bool Music.IsJustChanged Turns true every one frame of sixteenth notes. Ex. Paddle.cs↓ damage blink animation.
Step4-2. Linear animation float Music.MusicalTime float Music.MusicalTimeFrom(Timing) Get float time of music. Ex. Padddle.cs↓ paddle showing animation in the beginning.
Step4-3. Swing animation float Music.MusicalCos(cycle, offset, min, max) return cos value that swings from max=1 to min=0. Ex. Field.cs↓ field floor & wall color animations.
Step5. Scene transition with the music EASY TO TRANSITION
Step5-1. Seek music to change scene. Music.Seek(Timing)/SeekToSection(string name) Seek to any musical timing. Ex. Ball.cs↓ Game over logic. Ex. Field.cs↓ Restart logic.
Step5-2. Change scene by section info. Music.CurrentSection Get current section info. Ex. Field.cs↓I used section name as a scene.
Done. MUSIC IS (KIND OF) A MASTER CLOCK OF THIS GAME.
Difference between Unity+ADX2LE version & Unity StandAlone IT’S ALMOST SAME.
Use Block instead of Section Use “Block Resequencing” technique together. No tempo & meter change inside a music. Each block starts from (0,0,0) timing. Fit the wave length to the block. like this.