Esempio n. 1
0
        public bool CompareTracks(Track t1, Track t2)
        {
            if (t1.trackLength == t2.trackLength)
            {
                for (int i = 0; i < t1.trackLength; i++)
                {
                    //If both slots are empty, ignore
                    if (t1.samples[i] == null && t2.samples[i] == null) { }
                    //If one is empty, not a match
                    else if ((t1.samples[i] != null && t2.samples[i] == null) || (t1.samples[i] == null && t2.samples[i] != null))
                    {
                        return false;
                    }
                    //If both are filled, compare them
                    else if (t1.samples[i] != null && t2.samples[i] != null)
                    {
                        //If they are the same sound, move on to the next
                        if (t1.samples[i].name.Equals(t2.samples[i].name)) { }
                        else return false;
                    }
                    else return false;

                }
                return true;
            }
            else return false;
        }
Esempio n. 2
0
 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]);
 }
Esempio n. 3
0
 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));
 }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
 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]);
 }
Esempio n. 6
0
 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]);
 }
Esempio n. 7
0
 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>
        /// 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();
        }