MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / getPosition

Method getPosition

Source/VSTPlayhead.cpp:29–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27#include "Transport.h"
28
29juce::Optional<juce::AudioPlayHead::PositionInfo> VSTPlayhead::getPosition() const
30{
31 PositionInfo pos;
32 juce::AudioPlayHead::TimeSignature timeSignature;
33 juce::AudioPlayHead::LoopPoints loopPoint;
34 timeSignature.numerator = TheTransport->GetTimeSigTop();
35 timeSignature.denominator = TheTransport->GetTimeSigBottom();
36
37 juce::Optional<juce::AudioPlayHead::TimeSignature> posTM = pos.getTimeSignature();
38
39 loopPoint.ppqStart = 0;
40 loopPoint.ppqEnd = 480;
41
42 if (posTM)
43 {
44 loopPoint.ppqEnd *= posTM->denominator;
45 }
46
47 pos.setBpm(TheTransport->GetTempo());
48 pos.setTimeSignature(timeSignature);
49 pos.setTimeInSamples(int64_t(gTime * gSampleRateMs));
50 pos.setTimeInSeconds(gTime / 1000);
51
52 /*
53 * getMeasureTime is a float of how many measures we are through with fractional
54 * measures. We want to know the number of quarter notes from the epoch which is
55 * just the tsRatio times measure count, and for start of measure we simply floor
56 * the measure time
57 */
58
59 double tsRatio = 4;
60 if (pos.getTimeSignature()->numerator > 0)
61 tsRatio = 1.0 * pos.getTimeSignature()->numerator / pos.getTimeSignature()->denominator * 4;
62 pos.setPpqPosition((TheTransport->GetMeasureTime(gTime)) * tsRatio);
63 pos.setPpqPositionOfLastBarStart(floor(TheTransport->GetMeasureTime(gTime)) * tsRatio);
64
65 pos.setIsPlaying(true);
66 pos.setIsRecording(false);
67 pos.setIsLooping(false);
68 pos.setLoopPoints(loopPoint);
69 pos.setFrameRate(juce::AudioPlayHead::fps60);
70
71 return pos;
72}

Callers 10

bootstrap.jsFile · 0.80
bootstrap.min.jsFile · 0.80
GetSizeMethod · 0.80
PeekMethod · 0.80
GetFilePositionMethod · 0.80
OnConsoleInputMethod · 0.80
MainContentComponentMethod · 0.80
mouseUpMethod · 0.80
mouseDragMethod · 0.80
mouseMagnifyMethod · 0.80

Calls 4

GetTimeSigTopMethod · 0.80
GetTimeSigBottomMethod · 0.80
GetMeasureTimeMethod · 0.80
GetTempoMethod · 0.45

Tested by

no test coverage detected