void testBasic() { // gain -- single sample Jamoma::Gain my_gain; Jamoma::Sample x = 1.0; Jamoma::Sample y = 0.0; my_gain.gain = 0.5; y = my_gain(x); mTest->TEST_ASSERT("single sample gain", mTest->compare(y, 0.5)); // gain -- vector Jamoma::SampleBundle in_samples(2, 8); in_samples.fill(1.0); auto out_samples = my_gain(in_samples); mTest->TEST_ASSERT("vector sample gain left 0", mTest->compare(out_samples[0][0][0], 0.5)); mTest->TEST_ASSERT("vector sample gain right 0", mTest->compare(out_samples[0][1][0], 0.5)); mTest->TEST_ASSERT("vector sample gain left 1", mTest->compare(out_samples[0][0][1], 0.5)); mTest->TEST_ASSERT("vector sample gain right 2", mTest->compare(out_samples[0][1][1], 0.5)); my_gain.gain = 0.25; in_samples = out_samples; out_samples = my_gain(in_samples); mTest->TEST_ASSERT("vector b sample gain left 0", mTest->compare(out_samples[0][0][0], 0.125)); mTest->TEST_ASSERT("vector b sample gain right 0", mTest->compare(out_samples[0][1][0], 0.125)); mTest->TEST_ASSERT("vector b sample gain left 1", mTest->compare(out_samples[0][0][1], 0.125)); mTest->TEST_ASSERT("vector b sample gain right 2", mTest->compare(out_samples[0][1][1], 0.125)); }
void testParameterSetting() { Jamoma::Gain g; using namespace Dataspace; using namespace std; g.gain = make_pair(0.25, Unit::linearGain); mTest->TEST_ASSERT("setting gain param linearly", mTest->compare( g(1.0), 0.25) ); g.gain = make_pair(-6.0, Unit::db); mTest->TEST_ASSERT("setting gain param in db", mTest->compare( g(1.0), 0.50118723362727224) ); g.gain = make_pair(110.0, Unit::midiGain); mTest->TEST_ASSERT("setting gain param with midi", mTest->compare( g(1.0), 1.5826306885735968) ); }
void testBasic() { Jamoma::Gain my_gain; Jamoma::SampleBundle in_samples(2, 8); my_gain.gain = 0.5; in_samples.fill(1.0); auto out_samples = my_gain(in_samples); my_gain.gain = 0.25; in_samples = out_samples; out_samples = my_gain(in_samples); auto bar = in_samples[0][0]; mTest->TEST_ASSERT("in_sample casting operator", mTest->compare(bar, 0.5)); in_samples[0][0] = 2.0; auto foo = in_samples[0][0]; mTest->TEST_ASSERT("setting and getting", mTest->compare(foo, 2.0)); }
void testParameterSetting() { Jamoma::Phasor p; using namespace Dataspace; using namespace std; // Gain parameter (gain dataspace) p.gain = make_pair(0.25, Unit::linearGain); mTest->TEST_ASSERT("setting gain param linearly", mTest->compare( (double)p.gain, 0.25) ); p.gain = make_pair(-6.0, Unit::db); mTest->TEST_ASSERT("setting gain param in db", mTest->compare( (double)p.gain, 0.50118723362727224) ); p.gain = make_pair(110.0, Unit::midiGain); mTest->TEST_ASSERT("setting gain param with midi", mTest->compare( (double)p.gain, 1.5826306885735968) ); // Phase parameter (range wrapping) p.phase = 0.25; mTest->TEST_ASSERT("setting phase param within range", mTest->compare( (double)p.phase, 0.25) ); p.phase = 1.3; mTest->TEST_ASSERT("setting phase param over range", mTest->compare( (double)p.phase, 0.3) ); p.phase = 2.45; mTest->TEST_ASSERT("setting phase param way over range", mTest->compare( (double)p.phase, 0.45) ); p.phase = -1.3; mTest->TEST_ASSERT("setting phase param under range", mTest->compare( (double)p.phase, 0.7) ); // Frequency parameter (range folding) p.sampleRate = 96000; p.frequency = 1000.0; mTest->TEST_ASSERT("setting frequency param within range", mTest->compare( (double)p.frequency, 1000.0) ); p.frequency = 50000.0; mTest->TEST_ASSERT("setting frequency param way above range", mTest->compare( (double)p.frequency, 46000.0) ); p.frequency = 98000.0; mTest->TEST_ASSERT("setting frequency param way above range", mTest->compare( (double)p.frequency, 2000.0) ); p.frequency = -2000.0; mTest->TEST_ASSERT("setting frequency param below range", mTest->compare( (double)p.frequency, 2000.0) ); }
void testBasic() { // Test setting and getting of a Function { // Simplest Case String s; Function f = [&s]{ s = "Hello World"; }; Var<Function> v = f; Function f1 = v; mTest->TEST_ASSERT("s is empty", s == ""); f1(); mTest->TEST_ASSERT("s is has been filled-in", s == "Hello World"); // Now test it using more generic version. VarBase& vbr = v; // this one asserts because we request an incorrect type // int i = vbr; Function f3 = vbr; s = "foo"; f3(); mTest->TEST_ASSERT("s is has been filled-in again", s == "Hello World"); } // Test Pairs (e.g. TaggedValue) { auto a = Tag(-6.0, Unit::db); Var<TaggedValue<double>> v = a; VarBase vb = a; TaggedValue<double> out = v; mTest->TEST_ASSERT("TaggedValue, first item is returned correctly", mTest->compare(out.first, -6.0)); mTest->TEST_ASSERT("TaggedValue, second item is returned correctly", out.second == Unit::db); out = vb; mTest->TEST_ASSERT("TaggedValue (value assigned from value base by value), first item is returned correctly", mTest->compare(out.first, -6.0)); mTest->TEST_ASSERT("TaggedValue (value assigned from value base by value), second item is returned correctly", out.second == Unit::db); // normal copy assignment auto c = a; out = c; mTest->TEST_ASSERT("TaggedValue (value assigned from value), first item is returned correctly", mTest->compare(out.first, -6.0)); mTest->TEST_ASSERT("TaggedValue (value assigned from value), second item is returned correctly", out.second == Unit::db); // the follow asserts, as it should, because the type requested doesn't match the content // std::pair<double, int> foo = vb; // TODO: passing to a parameter? } // Jamoma::Value val0; // Jamoma::Value val1 = 3.14; // Jamoma::Value val2(3.14); // val0 = 3.14; // bool equal = (val1 == val2); // mTest->TEST_ASSERT("comparison", equal); // double f1 = val1; // double f2 = val2; // if (f1 == f2) // ; /* Jamoma::Var v0; // empty -- how do we test it? Jamoma::Var v1 = {3.14}; Jamoma::Var v2(3.14); // should yield the same result as the above f1 = v1; f2 = v2; equal = (v1 == v2); mTest->TEST_ASSERT("comparison", equal); */ }