Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- source=midi is now working
  • Loading branch information
vanvught committed Jan 24, 2025
1 parent 32d54fe commit 4c2f53e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib-ltc/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="([^/\\\\]*)((g?cc)|([gc]\+\+)|(clang))" prefer-non-shared="true"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1913103109102427337" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -std=c++20 -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1350242264437299605" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -std=c++20 -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
3 changes: 2 additions & 1 deletion lib-ltc/include/arm/ltcoutputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class LtcOutputs {
public:
LtcOutputs(const ltc::Source source, const bool bShowSysTime);

void Init();
void Init(const bool bDisableRtpMidi = false);
void Update(const struct ltc::TimeCode *ptLtcTimeCode);

void ShowSysTime();
Expand All @@ -51,6 +51,7 @@ class LtcOutputs {
private:
bool m_bShowSysTime;
bool m_bMidiQuarterFramePieceRunning { false };
bool m_bEnableRtpMidi { false };

ltc::Type m_TypePrevious { ltc::Type::INVALID };
int32_t m_nSecondsPrevious { 60 };
Expand Down
6 changes: 3 additions & 3 deletions lib-ltc/include/arm/midireader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file midireader.h
*
*/
/* Copyright (C) 2019-2024 by Arjan van Vught mailto:[email protected]
/* Copyright (C) 2019-2025 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -42,11 +42,11 @@ class MidiReader {
void Update();

private:
uint32_t m_nMtcQfFramePrevious { 0 };
uint32_t m_nMtcQfFramesDelta { 0 };
midi::TimecodeType m_TimeCodeType { midi::TimecodeType::UNKNOWN };
uint8_t m_nPartPrevious { 0 };
bool m_bDirection { true };
uint32_t m_nMtcQfFramePrevious { 0 };
uint32_t m_nMtcQfFramesDelta { 0 };
MidiBPM m_MidiBPM;
};

Expand Down
11 changes: 6 additions & 5 deletions lib-ltc/src/arm/ltcoutputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,15 @@ LtcOutputs::LtcOutputs(const ltc::Source source, const bool bShowSysTime): m_bSh
DEBUG_EXIT
}

void LtcOutputs::Init() {
void LtcOutputs::Init(const bool bDisableRtpMidi) {
DEBUG_ENTRY

m_bEnableRtpMidi = ltc::Destination::IsEnabled(ltc::Destination::Output::RTPMIDI) && !bDisableRtpMidi;
m_TypePrevious = ltc::Type::INVALID;
m_bMidiQuarterFramePieceRunning = false;
sv_nMidiQuarterFramePiece = 0;

if (ltc::Destination::IsEnabled(ltc::Destination::Output::RTPMIDI) || ltc::Destination::IsEnabled(ltc::Destination::Output::MIDI)) {
if (m_bEnableRtpMidi || ltc::Destination::IsEnabled(ltc::Destination::Output::MIDI)) {
#if defined (H3)
irq_timer_set(IRQ_TIMER_1, static_cast<thunk_irq_timer_t>(irq_timer1_midi_handler));
#elif defined (GD32)
Expand Down Expand Up @@ -201,7 +202,7 @@ void LtcOutputs::Update(const struct ltc::TimeCode *pLtcTimeCode) {
m_bMidiQuarterFramePieceRunning = false;
sv_nMidiQuarterFramePiece = 0;

if (ltc::Destination::IsEnabled(ltc::Destination::Output::RTPMIDI)) {
if (m_bEnableRtpMidi) {
RtpMidi::Get()->SendTimeCode(reinterpret_cast<const struct midi::Timecode *>(pLtcTimeCode));
}

Expand Down Expand Up @@ -238,7 +239,7 @@ void LtcOutputs::Update(const struct ltc::TimeCode *pLtcTimeCode) {

const auto data = create_quarter_frame(reinterpret_cast<const struct midi::Timecode *>(pLtcTimeCode));

if (ltc::Destination::IsEnabled(ltc::Destination::Output::RTPMIDI)) {
if (m_bEnableRtpMidi) {
RtpMidi::Get()->SendQf(data);
}

Expand All @@ -257,7 +258,7 @@ void LtcOutputs::Update(const struct ltc::TimeCode *pLtcTimeCode) {
__DMB();
}

m_bMidiQuarterFramePieceRunning = true;
m_bMidiQuarterFramePieceRunning = (m_bEnableRtpMidi || ltc::Destination::IsEnabled(ltc::Destination::Output::MIDI));

if (ltc::Destination::IsEnabled(ltc::Destination::Output::NTP_SERVER)) {
NtpServer::Get()->SetTimeCode(pLtcTimeCode);
Expand Down
28 changes: 16 additions & 12 deletions lib-ltc/src/arm/midireader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@
#include "ltcsender.h"
#include "artnetnode.h"
#include "ltcetc.h"
#include "net/rtpmidi.h"
#include "arm/ltcmidisystemrealtime.h"
#include "arm/ltcoutputs.h"

#include "arm/platform_ltc.h"

#include "debug.h"

static uint8_t s_qf[8] __attribute__ ((aligned (4))) = { 0, 0, 0, 0, 0, 0, 0, 0 };

#if defined (H3)
Expand All @@ -74,6 +77,9 @@ void MidiReader::Start() {
#endif
Midi::Get()->Init(midi::Direction::INPUT);

LtcOutputs::Get()->Init(true);
Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL);

DEBUG_EXIT
}

Expand All @@ -93,6 +99,10 @@ void MidiReader::HandleMtc() {
g_ltc_LtcTimeCode.nFrames = pSystemExclusive[8];
g_ltc_LtcTimeCode.nType = static_cast<uint8_t>(pSystemExclusive[5] >> 5);

if (ltc::Destination::IsEnabled(ltc::Destination::Output::RTPMIDI)) {
RtpMidi::Get()->SendTimeCode(reinterpret_cast<const struct midi::Timecode *>(&g_ltc_LtcTimeCode));
}

Update();

gv_ltc_bTimeCodeAvailable = false;
Expand All @@ -101,6 +111,11 @@ void MidiReader::HandleMtc() {
void MidiReader::HandleMtcQf() {
uint8_t nData1, nData2;
Midi::Get()->GetMessageData(nData1, nData2);

if (ltc::Destination::IsEnabled(ltc::Destination::Output::RTPMIDI)) {
RtpMidi::Get()->SendQf(nData1);
}

const auto nPart = static_cast<uint8_t>((nData1 & 0x70) >> 4);

s_qf[nPart] = nData1 & 0x0F;
Expand Down Expand Up @@ -138,7 +153,7 @@ void MidiReader::HandleMtcQf() {
#if defined (H3)
H3_TIMER->TMR1_CTRL |= TIMER_CTRL_SINGLE_MODE;
H3_TIMER->TMR1_INTV = TimeCodeConst::TMR_INTV[g_ltc_LtcTimeCode.nType];
H3_TIMER->TMR1_CTRL |= (TIMER_CTRL_EN_START | TIMER_CTRL_RELOAD);
H3_TIMER->TMR1_CTRL |= (TIMER_CTRL_EN_START);
#elif defined (GD32)
platform::ltc::timer11_set_type(g_ltc_LtcTimeCode.nType);
#endif
Expand Down Expand Up @@ -245,17 +260,6 @@ void MidiReader::Run() {
}

Update();

if (m_nMtcQfFramesDelta == 2) {
m_nMtcQfFramesDelta = 0;
#if defined (H3)
H3_TIMER->TMR1_CTRL |= TIMER_CTRL_SINGLE_MODE;
H3_TIMER->TMR1_INTV = TimeCodeConst::TMR_INTV[g_ltc_LtcTimeCode.nType];
H3_TIMER->TMR1_CTRL |= (TIMER_CTRL_EN_START | TIMER_CTRL_RELOAD);
#elif defined (GD32)
platform::ltc::timer11_set_type(g_ltc_LtcTimeCode.nType);
#endif
}
}

if (Midi::Get()->GetUpdatesPerSecond() != 0) {
Expand Down

0 comments on commit 4c2f53e

Please sign in to comment.