internal Instrument(IOrchestra orchestra, InstrumentType instrumentType, Scale scale, int octave = 0) { Scale = scale; Octave = octave; _orchestra = orchestra; InstrumentType = instrumentType; }
public void ParallelGetChildrenTest() { MusicObject[] testObjects = new MusicObject[5]; testObjects[0] = new Keystroke(Tone.A, 2); testObjects[1] = new Pause(1); testObjects[2] = new Keystroke(Tone.B, 3); testObjects[3] = new Pause(1); testObjects[4] = new Keystroke(Tone.D, 5); List <SingleBeat> sTestList = new List <SingleBeat>(); ParallelMusicCollection sTestCollection = new ParallelMusicCollection(testObjects); IOrchestra testOrc = Substitute.For <IOrchestra>(); Instrument i = new Instrument(testOrc, InstrumentType.AcousticBass, new Scale()); sTestList.AddRange(sTestCollection.GetChildren(i, 1)); double testDouble = 1; foreach (SingleBeat sb in sTestList) { if (sb.ToneStartTime != testDouble && (sb.ToneVelocity != 0xff && sb.Tone != 0xff)) { Assert.Fail(); } } }
public void SequentialGetChildrenTest2() { MusicObject[] testObjects = new MusicObject[5]; testObjects[0] = new Keystroke(Tone.A, 2); testObjects[1] = new Pause(1); testObjects[2] = new ChordVariety(1, 4, 7).WithBaseTone(Tone.E, 2); testObjects[3] = new Pause(1); testObjects[4] = new Keystroke(Tone.D, 2); List <SingleBeat> sSBList = new List <SingleBeat>(); SequentialMusicList sTestList = new SequentialMusicList(testObjects); IOrchestra testOrc = Substitute.For <IOrchestra>(); Instrument i = new Instrument(testOrc, InstrumentType.AcousticBass, new Scale()); sSBList.AddRange(sTestList.GetChildren(i, 1)); int testInt = 0; double testDouble = 0; foreach (SingleBeat sb in sSBList) { if ((sb.ToneStartTime > testDouble)) { testInt++; } testDouble = sb.ToneStartTime; } Assert.IsTrue(testInt == 3); }
public void SequentialGetChildrenTest() { MusicObject[] testObjects = new MusicObject[5]; testObjects[0] = new Keystroke(Tone.A, 2); testObjects[1] = new Pause(1); testObjects[2] = new Keystroke(Tone.B, 3); testObjects[3] = new Pause(1); testObjects[4] = new Keystroke(Tone.D, 5); List <SingleBeat> sSBList = new List <SingleBeat>(); SequentialMusicList sTestList = new SequentialMusicList(testObjects); IOrchestra testOrc = Substitute.For <IOrchestra>(); Instrument i = new Instrument(testOrc, InstrumentType.AcousticBass, new Scale()); sSBList.AddRange(sTestList.GetChildren(i, 1)); double testDouble = 0; foreach (SingleBeat sb in sSBList) { if (!(sb.ToneStartTime >= testDouble)) { Assert.Fail(); } testDouble = sb.ToneStartTime; } }
public void GetChildrenTest(int octave, Tone tone, byte expectedPitch) { IOrchestra o = Substitute.For <IOrchestra>(); Instrument i = new Instrument(o, InstrumentType.AcousticBass, new Scale(), octave); Keystroke n = new Keystroke(tone, 22, 33); SingleBeat actual = n.GetChildren(i, 0).First(); SingleBeat expected = new SingleBeat(i.InstrumentType, expectedPitch, n.Velocity, 0, n.Duration); Assert.AreEqual(actual, expected); }
public void PlayTest_SimpleNewTone(int octave, Tone tone, int duration, byte velocity, byte expectedToneOffset) { IOrchestra o = Substitute.For <IOrchestra>(); Instrument i = new Instrument(o, InstrumentType.AcousticBass, new Scale(), octave); i.Play(tone, duration, velocity); List <SingleBeat> expected = new List <SingleBeat> { new SingleBeat(i.InstrumentType, expectedToneOffset, velocity, 0, duration) }; o.Received().CopyToOutput(Arg.Is <List <SingleBeat> >(value => value.SequenceEqual(expected))); }