tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_MidiInputDeviceNode.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
19{
20public:
22 MidiInputDevice&, MidiMessageArray::MPESourceID,
24 EditItemID targetID);
25 ~MidiInputDeviceNode() override;
26
29 bool isReadyToProcess() override;
30 void process (ProcessContext&) override;
31
32 void handleIncomingMidiMessage (const juce::MidiMessage&) override;
33 void discardRecordings (EditItemID) override;
34
35private:
36 //==============================================================================
37 InputDeviceInstance& instance;
38 MidiInputDevice& midiInputDevice;
39 const MidiMessageArray::MPESourceID midiSourceID = MidiMessageArray::notMPE;
41 const EditItemID targetID;
42 const size_t nodeID = hash ((size_t) midiSourceID, targetID);
43
44 unsigned int maxExpectedMsPerBuffer = 0;
45 double sampleRate = 44100.0;
46
47 LambdaTimer loopOverdubsChecker { [this] { updateLoopOverdubs(); } };
48
49 struct NodeState
50 {
51 NodeState()
52 {
53 for (int i = 256; --i >= 0;)
54 incomingMessages.add (new juce::MidiMessage (0x80, 0, 0));
55 }
56
57 std::atomic<MidiInputDeviceNode*> activeNode { nullptr };
58
59 std::mutex incomingMessagesMutex;
61 int numIncomingMessages = 0;
62
63 std::mutex liveMessagesMutex;
64 MidiMessageArray liveRecordedMessages;
65 int numLiveMessagesToPlay = 0; // the index of the first message that's been recorded in the current loop
66
68 double lastPlayheadTime = 0;
69 std::atomic<bool> canLoop { true };
70 };
71
73
74 //==============================================================================
75 void processSection (ProcessContext&, juce::Range<int64_t> timelineRange);
76 void createProgramChanges (MidiMessageArray&);
77 bool isLivePlayOverActive();
78 void updateLoopOverdubs();
79};
80
81}} // namespace tracktion { inline namespace engine
static uint32 getApproximateMillisecondCounter() noexcept
An instance of an InputDevice that's available to an Edit.
A Node that intercepts incoming live MIDI and inserts it in to the playback graph.
bool isReadyToProcess() override
Should return true when this node is ready to be processed.
void prepareToPlay(const tracktion::graph::PlaybackInitialisationInfo &) override
Called once before playback begins for each node.
void process(ProcessContext &) override
Called when the node is to be processed.
tracktion::graph::NodeProperties getNodeProperties() override
Should return the properties of the node.
void discardRecordings(EditItemID) override
This is called when a recording is aborted so listeners should trash their temp data.
void handleIncomingMidiMessage(const juce::MidiMessage &) override
Override this to receive MIDI input from the device if it has any.
Main graph Node processor class.
Struct to describe a single iteration of a process call.
Determines how this block releates to other previous render blocks and if the play head has jumped in...
unsigned int uint32
ID for objects of type EditElement - e.g.
Base class for classes that want to listen to an InputDevice and get a callback for each block of inp...
Holds some really basic properties of a node.
Passed into Nodes when they are being initialised, to give them useful contextual information that th...