public void SampleTest() { //creating a PianoWire PianoWire pw = new PianoWire(5, 25); //calling strike() method pw.Strike(); //storing the initial values of the array CircularArray buffer = pw.getWires(); double[] beforeSample = buffer.getValues(); double decay = 3; //adding new value to queue pw.Sample(decay); //Storing the new value of the array CircularArray buffer2 = pw.getWires(); double[] afterSample = buffer2.getValues(); double value = ((beforeSample[0] + beforeSample[1]) / 2) * decay; Assert.AreEqual(value, afterSample[0]); }
public void StrikeTest() { Piano testPiano = new Piano("q2we4r5ty7u8i9op-[=zxdcfvgbnjmk,.;/' ", 44100); testPiano.StrikeKey('q'); PianoWire testWire = (PianoWire)testPiano.returnKeyAtIndex('q'); Assert.AreNotEqual(0, testWire.getWires()[0]); }
public void PlayOneNoteTest() { //There isn't really a feasible way to test whether or not the sampling returned will add up to the same thing for two different piano's //so I just made copied over Piano testPiano = new Piano("q2we4r5ty7u8i9op-[=zxdcfvgbnjmk,.;/' ", 44100); testPiano.StrikeKey('q'); PianoWire testWire = (PianoWire)testPiano.returnKeyAtIndex('q'); double[] testArray = testWire.buffer.getValues(); Assert.AreEqual(testArray[0], testPiano.Play()); }
public void PlayMultipleNotesTest() { Piano testPiano = new Piano("q2we4r5ty7u8i9op-[=zxdcfvgbnjmk,.;/' ", 44100); testPiano.StrikeKey('q'); testPiano.StrikeKey('2'); testPiano.StrikeKey('w'); PianoWire testWire1 = (PianoWire)testPiano.returnKeyAtIndex('q'); PianoWire testWire2 = (PianoWire)testPiano.returnKeyAtIndex('2'); PianoWire testWire3 = (PianoWire)testPiano.returnKeyAtIndex('w'); double[] testArray1 = testWire1.buffer.getValues(); double[] testArray2 = testWire2.buffer.getValues(); double[] testArray3 = testWire3.buffer.getValues(); double result = testArray1[0] + testArray2[0] + testArray3[0]; Assert.AreEqual(result, testPiano.Play()); }
public void StrikeLowestTest() { //creating a new PianoWire PianoWire pw = new PianoWire(5, 25); pw.Strike(); //Stering a copy of the circular array into a new buffer CircularArray buffer = pw.getWires(); //storing the buffer values into a new array double[] temp = buffer.getValues(); //sorting the values of the array Array.Sort(temp); Assert.IsTrue(temp[0] <= 0.5); }