public void AddWrongTypeSampleToTrack() { Track t = new Track(8, "guitar", 0); Sample s = new Sample("./GuitarG.wav", "guitarChord", "banjo"); t.AddSample(3, s); Assert.AreNotEqual(s, t.samples[3]); }
public void CompareTracksDifferentLengths() { Track t1 = new Track(8, "guitar", 0); Track t2 = new Track(10, "guitar", 4); Sample s = new Sample("./GuitarG.wav", "guitarChord", "guitar"); t1.AddSample(3, s); t2.AddSample(3, s); Assert.IsFalse(CompareTracks(t1, t2)); }
/// <summary> /// The constructor takes the length the track needs to be, the type of track, and which order number it is. This is used to set the UI /// </summary> /// <param name="len"></param> /// <param name="trackType">What type the track is(guitar/bass/drums)</param> /// <param name="trackNo">The order number in the collection of tracks</param> public Track(int len, String trackType, int trackNo) { samples=new Sample[len]; isPlaying=true; trackLength=len; type=trackType; //Set up the UI Elements slots = new Rectangle[len]; trackUI = new Canvas { Height=100, Width=808, Margin=new System.Windows.Thickness(0,101*trackNo,0,0) }; //Add the UI Rectangle for each slot in the track for (int i = 0; i < trackLength; i++) { slots[i] = new Rectangle { Width = 100, Height = 100, Opacity=0.6, Margin = new System.Windows.Thickness(101 * i, 0, 0, 0), Fill = Brushes.PaleGreen, Name = "slot" + (i + 1) }; trackUI.Children.Add(slots[i]); } //Add a mute button to each track muteIcon = new Image(); volumeIcon = new Image(); muteIcon.Source = new BitmapImage(new Uri("Assets/Icons/muteIconWhite.png", UriKind.Relative)); volumeIcon.Source = new BitmapImage(new Uri("Assets/Icons/volumeIconWhite.png", UriKind.Relative)); mute = new Microsoft.Kinect.Toolkit.Controls.KinectTileButton { Margin = new System.Windows.Thickness(101 * trackLength, 0, 0, 0), Width = 100, Height = 100, Foreground = Brushes.White, Background = Brushes.RoyalBlue, }; mute.Content = volumeIcon; mute.Click+=new System.Windows.RoutedEventHandler(MuteButtonClick); trackUI.Children.Add(mute); }
public void CompareTracksDifferentTypes() { Track t1 = new Track(8, "guitar", 0); Track t2 = new Track(8, "drums", 4); Sample s = new Sample("./GuitarG.wav", "guitarChord", "guitar"); t1.AddSample(3, s); //Sample won't be added as it is a different type t2.AddSample(5, s); Assert.IsFalse(CompareTracks(t1, t2)); }
public void SwapSample() { Track t1 = new Track(8, "guitar", 0); Sample s1 = new Sample("./GuitarG.wav", "guitarChord", "guitar"); Sample s2 = new Sample("./GuitarD.wav", "guitarD", "guitar"); t1.AddSample(5, s1); t1.AddSample(2, s2); t1.SwapSamples(5, 2); Assert.AreEqual(s1, t1.samples[2]); }
public void SetSampleType() { String type = "GuItAr"; Sample s = new Sample("Assets/Sounds/GuitarG.wav", "GuitarThing", type); Assert.AreEqual(type, s.type); }
public void SetSampleSound() { String soundFile = "./GuitarG.wav"; WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); player.URL = soundFile; player.controls.play(); Sample s = new Sample(soundFile, "Test", "guitar"); Assert.AreEqual(player.currentMedia.name, s.player.currentMedia.name); }
public void SetSampleName() { string name = "drums beat"; Sample s = new Sample("Assets/Sounds/GuitarG.wav", name, "guitar"); Assert.AreEqual(name, s.name); }
public void RemoveSample() { Track t1 = new Track(8, "guitar", 0); Sample s1 = new Sample("./GuitarG.wav", "guitarChord", "guitar"); Sample s2 = new Sample("./GuitarD.wav", "guitarD", "guitar"); t1.AddSample(5, s1); t1.RemoveSample(5); Assert.AreNotEqual(s1, t1.samples[5]); }
public void MoveSample() { Track t1 = new Track(8, "guitar", 0); Sample s = new Sample("./GuitarG.wav", "guitarChord", "guitar"); t1.AddSample(5, s); t1.MoveSample(5, 2); Assert.AreEqual(s, t1.samples[2]); }
/// <summary> /// Adds an array of samples to a track in random positions /// </summary> /// <param name="samps">Array of samples</param> public void AddSamplesRandomly(Sample[] samps) { Random r=new Random(); foreach (var samp in samps) { //Check if the samples in the array are of the same type if (samp.type == type) { int i = r.Next(0, 7); bool x = true; while (x) { if (samples[i] == null) { AddSample(i, samp); x = false; } else i = r.Next(0, 7); } } else { //Don't add it to the track } } }
/// <summary> /// Adds the given Sample to the given slot /// </summary> /// <param name="i">The slot to insert the sample</param> /// <param name="s">The sample object that contains audio data</param> public void AddSample(int i, Sample s) { if (s.type == type) { samples[i] = s; s.isMoving = false; } }
/// <summary> /// Activates the win state. Updates the UI with a congratulatory message and starts an audience applause playing /// </summary> public void Win() { time.Stop(); consoleUI.Text = "Congrats you won!!"; applause = new Sample("Assets/Sounds/applause.wav", "Applause", "cheer"); applause.Play(); }
/// <summary> /// Loads all the animation, tracks, samples and Kinect objects into the game /// </summary> public void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { InitializeKinect(); //Load the animation timer, get the frames and start displaying it animationCurrentFrame = 0; animation = GetAnimationFrames(); animationTimer = new Timer(33); animationTimer.Elapsed += AnimationTimer_Tick; animationTimer.Start(); //Instantiate the tracks and the solution tracks array tracks = new Track[numberOfTracks]; solutionTracks = new Track[numberOfTracks]; //create all the samples in the game guitar[0] = new Sample("Assets/Sounds/GuitarC.wav", "C-Chord", "guitar"); guitar[1] = new Sample("Assets/Sounds/GuitarD.wav", "D-Chord", "guitar"); guitar[2] = new Sample("Assets/Sounds/GuitarG.wav", "G-Chord", "guitar"); guitar[3] = new Sample("Assets/Sounds/GuitarG.wav", "G-Chord", "guitar"); drums[0] = new Sample("Assets/Sounds/hihat.wav", "Hi-Hat", "drums"); drums[1] = new Sample("Assets/Sounds/hihat.wav", "Hi-Hat", "drums"); drums[2] = new Sample("Assets/Sounds/hihat.wav", "Hi-Hat", "drums"); drums[3] = new Sample("Assets/Sounds/hihat.wav", "Hi-Hat", "drums"); drums[4] = new Sample("Assets/Sounds/snare.wav", "Snare", "drums"); drums[5] = new Sample("Assets/Sounds/snare.wav", "Snare", "drums"); //Add the samples to the tracks at random tracks[0] = new Track(len, "guitar",0); tracks[0].AddSamplesRandomly(guitar); tracks[1] = new Track(len, "drums", 1); tracks[1].AddSamplesRandomly(drums); //Add the samples to the solution tracks in the correct order solutionTracks[0] = new Track(len, "guitar",0); solutionTracks[0].AddSample(0, guitar[0]); solutionTracks[0].AddSample(2, guitar[1]); solutionTracks[0].AddSample(4, guitar[2]); solutionTracks[0].AddSample(6, guitar[3]); solutionTracks[1] = new Track(len, "drums", 1); solutionTracks[1].AddSample(0, drums[0]); solutionTracks[1].AddSample(1, drums[1]); solutionTracks[1].AddSample(3, drums[4]); solutionTracks[1].AddSample(4, drums[2]); solutionTracks[1].AddSample(5, drums[3]); solutionTracks[1].AddSample(7, drums[5]); //Instantiate the solution tracks timer and it's tick event solutionTimer = new Timer(timerSpeed); solutionTimer.Elapsed += new ElapsedEventHandler(SolutionTimer_Tick); //Update the UI to draw the icons for each regular non-solution track foreach (Track t in tracks) { t.DrawIcons(); tracksUI.Children.Add(t.trackUI); } //Start the regular tracks timer time = new Timer(timerSpeed); time.Elapsed += new ElapsedEventHandler(Time_Tick); time.Start(); }