11namespace tracktion {
inline namespace engine
29 bool looping, TimeRange loopTimes)
31 time = currentTimeSeconds;
34 loopTimeRange = loopTimes;
36 loopStart.
set (loopTimeRange.getStart());
37 loopEnd.
set (loopTimeRange.getEnd());
38 currentPos.
set (time);
45 result.setFrameRate (getFrameRate());
49 result.setIsPlaying (isPlaying);
50 result.setIsLooping (isLooping);
51 result.setIsRecording (transport.isRecording());
52 result.setEditOriginTime (transport.getTimeWhenStarted().inSeconds());
57 result.setTimeInSeconds (time.
inSeconds());
58 result.setTimeInSamples (toSamples (time, plugin.getAudioPluginInstance()->
getSampleRate()));
61 result.setBpm (currentPos.
getTempo());
65 result.setPpqPositionOfLastBarStart (ppqPositionOfLastBarStart);
72 ExternalPlugin& plugin;
73 tempo::Sequence::Position currentPos {
createPosition (plugin.edit.tempoSequence) };
74 tempo::Sequence::Position loopStart {
createPosition (plugin.edit.tempoSequence) };
75 tempo::Sequence::Position loopEnd {
createPosition (plugin.edit.tempoSequence) };
77 bool isPlaying =
false, isLooping =
false;
80 AudioPlayHead::FrameRateType getFrameRate()
const
82 switch (plugin.edit.getTimecodeFormat().getFPS())
84 case 24:
return AudioPlayHead::fps24;
85 case 25:
return AudioPlayHead::fps25;
86 case 29:
return AudioPlayHead::fps30drop;
87 case 30:
return AudioPlayHead::fps30;
91 return AudioPlayHead::fps30;
100 : clip (c), playHead (ph),
101 clipLevel (clip.getLiveClipLevel()), clipPtr (&c),
102 melodyneProxy (c.melodyneProxy),
103 fileInfo (clip.getAudioFile().getInfo()),
104 isOfflineRender (isRendering)
109 updateAnalysingState();
111 if (analysingContent)
116MelodyneNode::~MelodyneNode()
120 if (
auto ep = melodyneProxy->getPlugin())
121 if (
auto p = ep->getAudioPluginInstance())
122 p->setPlayHead (
nullptr);
125 melodyneProxy =
nullptr;
132 props.hasAudio =
true;
133 props.numberOfChannels = fileInfo.numChannels;
135 if (
auto plugin = melodyneProxy->getPlugin())
136 if (
auto p = plugin->getAudioPluginInstance())
137 props.numberOfChannels =
juce::jmax (props.numberOfChannels, p->getTotalNumInputChannels(), p->getTotalNumOutputChannels());
150 if (
auto plugin = melodyneProxy->getPlugin())
152 if (
auto p = plugin->getAudioPluginInstance())
156 if (p->getSampleRate() != info.sampleRate
157 || p->getBlockSize() != info.blockSize)
159 plugin->initialise ({
TimePosition(), info.sampleRate, info.blockSize });
162 p->setPlayHead (
nullptr);
164 p->setPlayHead (playhead.get());
166 desc = p->getPluginDescription();
173 if (! isOfflineRender)
176 return ! analysingContent;
182 auto& dest = pc.buffers.audio;
184 if (dest.getNumFrames() == 0 || dest.getNumChannels() == 0 || melodyneProxy ==
nullptr)
187 if (
auto plugin = melodyneProxy->getPlugin())
189 if (
auto pluginInstance = plugin->getAudioPluginInstance())
191 if (pluginInstance->getPlayHead() != playhead.get())
192 pluginInstance->setPlayHead (playhead.get());
194 midiMessages.
clear();
200 const auto sampleRate = pluginInstance->getSampleRate();
201 playhead->setCurrentInfo (TimePosition::fromSamples (timelinePosition, sampleRate),
203 tracktion::timeRangeFromSamples (loopPositions, sampleRate));
206 auto asb = tracktion::graph::toAudioBuffer (dest);
207 pluginInstance->processBlock (asb, midiMessages);
211 if (asb.getNumChannels() > 1)
222 for (
int i = 0; i < asb.getNumChannels(); ++i)
224 const float gain = gains[i & 1];
227 asb.applyGain (i, 0, asb.getNumSamples(), gain);
234void MelodyneNode::updateAnalysingState()
236 TRACKTION_ASSERT_MESSAGE_THREAD
237 analysingContent = melodyneProxy->isAnalysingContent();
239 if (! analysingContent)
243void MelodyneNode::timerCallback()
245 updateAnalysingState();
double getSampleRate() const noexcept
constexpr ValueType getStart() const noexcept
void stopTimer() noexcept
void startTimerHz(int timerFrequencyHz) noexcept
TransportControl & getTransport() const noexcept
Returns the TransportControl which is used to stop/stop/position playback and recording.
This class is a necessary bodge due to ARA needing to be told that we're playing, even if we aren't,...
void setCurrentInfo(TimePosition currentTimeSeconds, bool playing, bool looping, TimeRange loopTimes)
Must be called before processing audio/MIDI.
tracktion::graph::NodeProperties getNodeProperties() override
Should return the properties of the node.
std::vector< Node * > getDirectInputNodes() override
Should return all the inputs directly feeding in to this node.
void process(ProcessContext &) override
Called when the node is to be processed.
void prepareToPlay(const tracktion::graph::PlaybackInitialisationInfo &) override
Called once before playback begins for each node.
bool isReadyToProcess() override
Should return true when this node is ready to be processed.
Struct to describe a single iteration of a process call.
Converts a monotonically increasing reference range in to a timeline range.
bool isUserDragging() const
Returns true if the user is dragging.
juce::Range< int64_t > getLoopRange() const noexcept
Returns the looped playback range.
bool isPlaying() const noexcept
Returns true is the play head is currently playing.
bool isLooping() const noexcept
Returns true is the play head is in loop mode.
constexpr Type jmax(Type a, Type b)
tempo::Sequence::Position createPosition(const TempoSequence &s)
Creates a Position to iterate over the given TempoSequence.
SplitTimelineRange referenceSampleRangeToSplitTimelineRange(const PlayHead &playHead, juce::Range< int64_t > referenceSampleRange)
Converts a reference sample range to a TimelinePositionWindow which could have two time ranges if the...
RangeType< TimePosition > TimeRange
A RangeType based on real time (i.e.
Represents a position in real-life time.
constexpr double inSeconds() const
Returns the TimePosition as a number of seconds.
double getPPQTimeOfBarStart() const noexcept
Returns the PPQ start time of the bar the position is in.
double getPPQTime() const noexcept
Returns the position as a PPQ time.
TimeSignature getTimeSignature() const
Returns the current TimeSignature of the Position.
void set(TimePosition)
Sets the Position to a new time.
double getTempo() const
Returns the current tempo of the Position.
float getGainIncludingMute() const noexcept
Returns the clip's gain if the clip is not muted.
void getLeftAndRightGains(float &left, float &right) const noexcept
Reutrns the left and right gains taking in to account mute and pan values.
Holds some really basic properties of a node.
Passed into Nodes when they are being initialised, to give them useful contextual information that th...
#define CRASH_TRACER
This macro adds the current location to a stack which gets logged if a crash happens.