public JetGameEvent (JetPlayer player, short segment, sbyte track, sbyte channel, sbyte controller, sbyte value) { Player = player; Segment = segment; Track = track; Channel = channel; Controller = controller; Value = value; }
public void onJetUserIdUpdate(JetPlayer player, int userId, int repeatCount) { // nothing to do }
public void OnJetPauseUpdate(JetPlayer player, int paused) { // nothing to do yet }
public void OnJetNumQueuedSegmentUpdate(JetPlayer player, int nbSegments) { // nothing to do }
// JetPlayer.OnJetEventListener implementation public void OnJetEvent(JetPlayer player, short segment, byte track, byte channel, byte controller, byte value) { // TODO Auto-generated method stub switch (controller) { case (byte) 0x90: // note on break; case (byte) 0x80: // note off break; } }
// Does the grunt work of setting up initial jet requirements private void InitializeJetPlayer() { // JET info: let's create our JetPlayer instance using the factory. // JET info: if we already had one, the same singleton is returned. mJet = JetPlayer.GetJetPlayer (); mJetPlaying = false; // JET info: make sure we flush the queue, // JET info: otherwise left over events from previous gameplay can hang around. // JET info: ok, here we don't really need that but if you ever reuse a JetPlayer // JET info: instance, clear the queue before reusing it, this will also clear any // JET info: trigger clips that have been triggered but not played yet. mJet.ClearQueue (); // JET info: we are going to receive in this example all the JET callbacks // JET info: inthis animation thread object. mJet.SetEventListener (this); Log.Debug (TAG, "opening jet file"); // JET info: load the actual JET content the game will be playing, // JET info: it's stored as a raw resource in our APK, and is labeled "level1" // JET info: if our JET file was stored on the sdcard for instance, we would have used // JET info: mJet.loadJetFile("/sdcard/level1.jet"); mJet.LoadJetFile (mContext.Resources.OpenRawResourceFd (Resource.Raw.level1)); Log.Debug (TAG, "opening jet file DONE"); mCurrentBed = 0; sbyte sSegmentID = 0; Log.Debug (TAG, " start queuing jet file"); // JET info: now we're all set to prepare queuing the JET audio segments for the game. // JET info: in this example, the game uses segment 0 for the duration of the game play, // JET info: and plays segment 1 several times as the "outro" music, so we're going to // JET info: queue everything upfront, but with more complex JET compositions, we could // JET info: also queue the segments during the game play. // JET info: this is the main game play music // JET info: it is located at segment 0 // JET info: it uses the first DLS lib in the .jet resource, which is at index 0 // JET info: index -1 means no DLS mJet.QueueJetSegment (0, 0, 0, 0, 0, sSegmentID); // JET info: end game music, loop 4 times normal pitch mJet.QueueJetSegment (1, 0, 4, 0, 0, sSegmentID); // JET info: end game music loop 4 times up an octave mJet.QueueJetSegment (1, 0, 4, 1, 0, sSegmentID); // JET info: set the mute mask as designed for the beginning of the game, when the // JET info: the player hasn't scored yet. mJet.SetMuteArray (muteMask[0], true); Log.Debug (TAG, " start queuing jet file DONE"); }
// This method handles the state updates that can be caused by JET // events. protected void ProcessJetEvent(JetPlayer player, short segment, sbyte track, sbyte channel, sbyte controller, sbyte value) { // Check for an event that triggers a new asteroid if (value == NEW_ASTEROID_EVENT) DoAsteroidCreation (); mBeatCount++; if (mBeatCount > 4) mBeatCount = 1; // Scale the music based on progress // it was a game requirement to change the mute array on 1st beat of // the next measure when needed // and so we track beat count, after that we track hitStreak to // determine the music "intensity" // if the intensity has go gone up, call a corresponding trigger clip, otherwise just // execute the rest of the music bed change logic. if (mBeatCount == 1) { // do it back wards so you fall into the correct one if (scores.HitStreak > 28) { // did the bed change? if (mCurrentBed != 7) { // did it go up? if (mCurrentBed < 7) mJet.TriggerClip (7); mCurrentBed = 7; // JET info: change the mute mask to update the way the music plays based // JET info: on the player's skills. mJet.SetMuteArray (muteMask[7], false); } } else if (scores.HitStreak > 24) { if (mCurrentBed != 6) { if (mCurrentBed < 6) { // JET info: quite a few asteroids hit, trigger the clip with the guy's // JET info: voice that encourages the player. mJet.TriggerClip (6); } mCurrentBed = 6; mJet.SetMuteArray (muteMask[6], false); } } else if (scores.HitStreak > 20) { if (mCurrentBed != 5) { if (mCurrentBed < 5) { mJet.TriggerClip (5); } mCurrentBed = 5; mJet.SetMuteArray (muteMask[5], false); } } else if (scores.HitStreak > 16) { if (mCurrentBed != 4) { if (mCurrentBed < 4) { mJet.TriggerClip (4); } mCurrentBed = 4; mJet.SetMuteArray (muteMask[4], false); } } else if (scores.HitStreak > 12) { if (mCurrentBed != 3) { if (mCurrentBed < 3) { mJet.TriggerClip (3); } mCurrentBed = 3; mJet.SetMuteArray (muteMask[3], false); } } else if (scores.HitStreak > 8) { if (mCurrentBed != 2) { if (mCurrentBed < 2) { mJet.TriggerClip (2); } mCurrentBed = 2; mJet.SetMuteArray (muteMask[2], false); } } else if (scores.HitStreak > 4) { if (mCurrentBed != 1) { if (mCurrentBed < 1) { mJet.TriggerClip (1); } mJet.SetMuteArray (muteMask[1], false); mCurrentBed = 1; } } } }
public void OnJetUserIdUpdate(JetPlayer player, int userId, int repeatCount) { }
public void OnJetPauseUpdate(JetPlayer player, int paused) { }
public void OnJetNumQueuedSegmentUpdate(JetPlayer player, int nbSegments) { }
public void OnJetEvent(JetPlayer player, short segment, sbyte track, sbyte channel, sbyte controller, sbyte value) { // Events fire outside the animation thread. This can cause timing issues. // put in queue for processing by animation thread. mEventQueue.Enqueue (new JetGameEvent (player, segment, track, channel, controller, value)); }