#include namespace te = tracktion_engine; class MainComponent : public Component, private te::EngineBehaviour { public: MainComponent() { setCentreRelative(0.5f, 0.5f); setSize(1280, 720); trackInput->pluginList.insertPlugin(*fourOscPlugin, 0, nullptr); String fourOscPatch = " "; XmlDocument doc(fourOscPatch); if (auto e = doc.getDocumentElement()) { auto vt = juce::ValueTree::fromXml(*e); if (vt.isValid()) { fourOscPlugin->restorePluginStateFromValueTree(vt); } } te::MidiClip* clipInput = dynamic_cast(trackInput->insertNewClip(te::TrackItem::Type::midi, "Clip 3", te::EditTimeRange{ 0.0, 4 * _edit.tempoSequence.barsBeatsToTime({ 1, 0.0 }) }, nullptr)); clipInput->getSequence().addNote(70, 1.0, 1.0, 1, 0, nullptr); clipInput->getSequence().addNote(70, 2.0, 1.0, 1, 0, nullptr); clipInput->getSequence().addNote(70, 3.0, 1.0, 1, 0, nullptr); clipInput->getSequence().addNote(72, 4.0, 1.0, 1, 0, nullptr); clipInput->getSequence().addNote(74, 5.0, 2.0, 1, 0, nullptr); clipInput->getSequence().addNote(72, 7.0, 2.0, 1, 0, nullptr); clipInput->getSequence().addNote(70, 9.0, 1.0, 1, 0, nullptr); clipInput->getSequence().addNote(74, 10.0, 1.0, 1, 0, nullptr); clipInput->getSequence().addNote(72, 11.0, 1.0, 1, 0, nullptr); clipInput->getSequence().addNote(72, 12.0, 1.0, 1, 0, nullptr); clipInput->getSequence().addNote(70, 13.0, 4.0, 1, 0, nullptr); /* Recording the output of one track (trackInput) to another (trackDest) */ te::InputDevice& inputDevice = trackInput->getWaveInputDevice(); // setup WaveTrackInput. AudioTrack::getWaveInputDevice is for assigning the output of one track to the input of another _edit.getEditInputDevices().getInstanceStateForInputDevice(inputDevice); // make the track's InputDeviceInstance visible to the EditPlaybackContext if (auto epc = _edit.getCurrentPlaybackContext()) { if (auto sourceTrackInputDeviceInstance = epc->getInputFor(&inputDevice)) { sourceTrackInputDeviceInstance->setTargetTrack(*trackDest, 0, true); sourceTrackInputDeviceInstance->setRecordingEnabled(*trackDest, true); } } _transport.record(false, true); Timer::callAfterDelay(8000, [this]() { _transport.stop(false, false); AlertWindow::showMessageBoxAsync(MessageBoxIconType::NoIcon, "Rendered", "Size: " + String(trackDest->getClips().size())); } ); } private: te::Engine _engine{ ProjectInfo::projectName }; te::Edit::Options _options{ _engine, te::createEmptyEdit(_engine), te::ProjectItemID::createNewID(0), te::Edit::forEditing }; te::Edit _edit{ _options }; te::TransportControl& _transport{ _edit.getTransport() }; te::AudioTrack* trackInput{ _edit.insertNewAudioTrack(te::TrackInsertPoint(nullptr, nullptr), nullptr).get() }; te::AudioTrack* trackDest{ _edit.insertNewAudioTrack(te::TrackInsertPoint(nullptr, nullptr), nullptr).get() }; te::FourOscPlugin* fourOscPlugin = dynamic_cast (_edit.getPluginCache().createNewPlugin(te::FourOscPlugin::xmlTypeName, {}).get()); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainComponent) };