MultiChannelTest.cpp (2792B)
1 #include "PluginProcessor.h" 2 3 class MultiChannelTest : public UnitTest 4 { 5 using Proc = ChowtapeModelAudioProcessor; 6 7 public: 8 MultiChannelTest() : UnitTest ("MultiChannelTest") {} 9 10 using Layout = AudioProcessor::BusesLayout; 11 Layout getLayout (AudioChannelSet channelSet) 12 { 13 Layout layout; 14 layout.inputBuses.add (channelSet); 15 layout.outputBuses.add (channelSet); 16 return layout; 17 } 18 19 std::unique_ptr<Proc> createPlugin() 20 { 21 auto proc = createPluginFilterOfType (AudioProcessor::WrapperType::wrapperType_Standalone); 22 std::unique_ptr<Proc> plugin (dynamic_cast<Proc*> (proc)); 23 return std::move (plugin); 24 } 25 26 void multiChannelTest (const Layout& layout) 27 { 28 auto&& plugin = createPlugin(); 29 const auto ableToSetBusesLayout = plugin->setBusesLayout (layout); 30 expect (ableToSetBusesLayout, "Unable to set buses layout: " + layout.getMainInputChannelSet().getDescription()); 31 32 const auto& params = plugin->getParameters(); 33 for (auto* param : params) 34 { 35 if (auto* rangedParam = dynamic_cast<RangedAudioParameter*> (param)) 36 { 37 if (rangedParam->getParameterID().contains ("onoff")) 38 { 39 std::cout << "Turning on parameter: " << rangedParam->getName (1024) << std::endl; 40 rangedParam->setValueNotifyingHost (1.0f); 41 } 42 } 43 } 44 45 MessageManager::getInstance()->runDispatchLoopUntil (250); 46 47 constexpr double sampleRate = 48000.0; 48 constexpr int blockSize = 512; 49 const auto numChannels = layout.getMainInputChannels(); 50 std::cout << "Running plugin processing with channel count: " << numChannels << std::endl; 51 52 AudioBuffer<float> buffer (numChannels, blockSize); 53 MidiBuffer midi; 54 55 plugin->prepareToPlay (sampleRate, blockSize); 56 plugin->processBlock (buffer, midi); 57 } 58 59 void runTest() override 60 { 61 beginTest ("Mono Test"); 62 multiChannelTest (getLayout (AudioChannelSet::mono())); 63 64 beginTest ("Stereo Test"); 65 multiChannelTest (getLayout (AudioChannelSet::stereo())); 66 67 beginTest ("Quad Test"); 68 multiChannelTest (getLayout (AudioChannelSet::quadraphonic())); 69 70 beginTest ("5.0 Test"); 71 multiChannelTest (getLayout (AudioChannelSet::create5point0())); 72 73 beginTest ("5.1 Test"); 74 multiChannelTest (getLayout (AudioChannelSet::create5point1())); 75 76 beginTest ("7.0 Test"); 77 multiChannelTest (getLayout (AudioChannelSet::create7point0())); 78 79 beginTest ("7.1 Test"); 80 multiChannelTest (getLayout (AudioChannelSet::create7point1())); 81 } 82 }; 83 84 MultiChannelTest multiChannelTest;