Skip to content

Commit ec888e1

Browse files
committed
update 250512
1 parent d5195c9 commit ec888e1

File tree

89 files changed

+854
-332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+854
-332
lines changed

framework/accessibility/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ if (MUSE_MODULE_ACCESSIBILITY_TRACE)
5656
set(MODULE_DEF ${MODULE_DEF} -DMUSE_MODULE_ACCESSIBILITY_TRACE )
5757
endif()
5858

59+
if (QT_SUPPORT)
60+
list(APPEND MODULE_LINK Qt::Quick)
61+
endif()
62+
5963
setup_module()
6064

6165
if (MUSE_MODULE_ACCESSIBILITY_TESTS)

framework/actions/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ set(MODULE_SRC
3535
${CMAKE_CURRENT_LIST_DIR}/internal/actionsdispatcher.h
3636
)
3737

38+
if (QT_SUPPORT)
39+
list(APPEND MODULE_LINK Qt::Quick)
40+
endif()
41+
3842
setup_module()
3943

4044
if (MUSE_MODULE_ACTIONS_TESTS)

framework/audio/internal/abstracteventsequencer.h

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ class AbstractEventSequencer : public async::Asyncable
8989
}
9090
}
9191

92+
void flushOffstream()
93+
{
94+
if (m_offStreamEvents.empty()) {
95+
return;
96+
}
97+
98+
m_offStreamEvents.clear();
99+
updateOffSequenceIterator();
100+
101+
if (m_onOffStreamFlushed) {
102+
m_onOffStreamFlushed();
103+
}
104+
}
105+
92106
void setActive(const bool active)
93107
{
94108
if (m_isActive == active) {
@@ -158,20 +172,26 @@ class AbstractEventSequencer : public async::Asyncable
158172
EventSequenceMap result;
159173

160174
if (!m_isActive) {
161-
result.emplace(0, EventSequence());
162-
handleOffStream(result, nextMsecs);
175+
result.emplace(m_offstreamPosition, EventSequence());
176+
177+
if (m_currentOffSequenceIt == m_offStreamEvents.cend()) {
178+
return result;
179+
}
180+
181+
m_offstreamPosition += nextMsecs;
182+
handleOffStream(result);
183+
163184
return result;
164185
}
165186

166187
// Empty sequence means to continue the previous sequence
167188
result.emplace(m_playbackPosition, EventSequence());
189+
m_playbackPosition += nextMsecs;
168190

169191
if (m_currentMainSequenceIt == m_mainStreamEvents.cend()) {
170192
return result;
171193
}
172194

173-
m_playbackPosition += nextMsecs;
174-
175195
handleMainStream(result);
176196
handleDynamicChanges(result);
177197

@@ -198,29 +218,30 @@ class AbstractEventSequencer : public async::Asyncable
198218
void updateOffSequenceIterator()
199219
{
200220
m_currentOffSequenceIt = m_offStreamEvents.cbegin();
221+
m_offstreamPosition = 0;
201222
}
202223

203224
void updateDynamicChangesIterator()
204225
{
205226
m_currentDynamicsIt = m_dynamicEvents.lower_bound(m_playbackPosition);
206227
}
207228

208-
void handleOffStream(EventSequenceMap& result, const msecs_t nextMsecs)
229+
void handleOffStream(EventSequenceMap& result)
209230
{
210-
if (m_offStreamEvents.empty() || m_currentOffSequenceIt == m_offStreamEvents.cend()) {
231+
if (m_offStreamEvents.empty()) {
211232
return;
212233
}
213234

214-
if (m_currentOffSequenceIt->first <= nextMsecs) {
215-
while (m_currentOffSequenceIt != m_offStreamEvents.end()
216-
&& m_currentOffSequenceIt->first <= nextMsecs) {
217-
result.insert_or_assign(m_currentOffSequenceIt->first, std::move(m_currentOffSequenceIt->second));
218-
m_currentOffSequenceIt = m_offStreamEvents.erase(m_currentOffSequenceIt);
219-
}
220-
} else {
221-
auto node = m_offStreamEvents.extract(m_currentOffSequenceIt);
222-
node.key() -= nextMsecs;
223-
m_offStreamEvents.insert(std::move(node));
235+
while (m_currentOffSequenceIt != m_offStreamEvents.end()
236+
&& m_currentOffSequenceIt->first <= m_offstreamPosition) {
237+
EventSequence& sequence = result[m_currentOffSequenceIt->first];
238+
sequence.insert(m_currentOffSequenceIt->second.cbegin(),
239+
m_currentOffSequenceIt->second.cend());
240+
m_currentOffSequenceIt = std::next(m_currentOffSequenceIt);
241+
}
242+
243+
if (m_currentOffSequenceIt == m_offStreamEvents.end()) {
244+
m_offStreamEvents.clear();
224245
updateOffSequenceIterator();
225246
}
226247
}
@@ -252,6 +273,7 @@ class AbstractEventSequencer : public async::Asyncable
252273
}
253274

254275
mutable msecs_t m_playbackPosition = 0;
276+
mutable msecs_t m_offstreamPosition = 0;
255277

256278
SequenceIterator m_currentMainSequenceIt;
257279
SequenceIterator m_currentOffSequenceIt;

framework/audio/internal/synthesizers/fluidsynth/fluidsequencer.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ int FluidSequencer::naturalExpressionLevel() const
6161

6262
void FluidSequencer::updateOffStreamEvents(const mpe::PlaybackEventsMap& events, const PlaybackParamList&)
6363
{
64-
m_offStreamEvents.clear();
65-
66-
if (m_onOffStreamFlushed) {
67-
m_onOffStreamFlushed();
68-
}
69-
64+
flushOffstream();
7065
updatePlaybackEvents(m_offStreamEvents, events);
7166
updateOffSequenceIterator();
7267
}
@@ -131,7 +126,7 @@ void FluidSequencer::updatePlaybackEvents(EventSequenceMap& destination, const m
131126
midi::Event noteOn(Event::Opcode::NoteOn, Event::MessageType::ChannelVoice20);
132127
noteOn.setChannel(channelIdx);
133128
noteOn.setNote(noteIdx);
134-
noteOn.setVelocity(velocity);
129+
noteOn.setVelocity16(velocity);
135130
noteOn.setPitchNote(noteIdx, tuning);
136131

137132
destination[timestampFrom].emplace(std::move(noteOn));

framework/audio/internal/synthesizers/fluidsynth/fluidsynth.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ void FluidSynth::allNotesOff()
203203
port->sendEvent(e);
204204
}
205205
}
206+
207+
m_allNotesOffRequested = false;
206208
}
207209

208210
bool FluidSynth::handleEvent(const midi::Event& event)
@@ -364,6 +366,8 @@ void FluidSynth::flushSound()
364366
return;
365367
}
366368

369+
m_sequencer.flushOffstream();
370+
367371
allNotesOff();
368372

369373
fluid_synth_all_sounds_off(m_fluid->synth, -1);
@@ -408,7 +412,6 @@ samples_t FluidSynth::process(float* buffer, samples_t samplesPerChannel)
408412

409413
if (m_allNotesOffRequested) {
410414
allNotesOff();
411-
m_allNotesOffRequested = false;
412415
}
413416

414417
const msecs_t nextMsecs = samplesToMsecs(samplesPerChannel, m_sampleRate);

framework/audio/internal/synthesizers/fluidsynth/sfcachedloader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void* openSoundFont(const char* filename)
7171
return search->second.fileStream;
7272
}
7373

74-
std::FILE* stream = std::fopen(filename, "r");
74+
std::FILE* stream = std::fopen(filename, "rb");
7575

7676
SoundFontData sfData;
7777
sfData.fileStream = stream;

framework/audio/internal/synthesizers/fluidsynth/soundmapping.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ static const auto& mappingByCategory(const mpe::SoundCategory category)
649649

650650
{ { mpe::SoundId::Conga, {} }, { midi::Program(128, 48) } },
651651
{ { mpe::SoundId::Cuica, {} }, { midi::Program(128, 0) } },
652+
{ { mpe::SoundId::Cajon, {} }, { midi::Program(128, 40) } },
652653

653654
{ { mpe::SoundId::Drumset, {} }, { midi::Program(128, 0) } },
654655
{ { mpe::SoundId::Drumset, { mpe::SoundSubCategory::FourPiece } }, { midi::Program(128, 0) } },
@@ -719,7 +720,7 @@ static const auto& mappingByCategory(const mpe::SoundCategory category)
719720
{ { mpe::SoundId::Guiro, { mpe::SoundSubCategory::Wooden } }, { midi::Program(128, 0) } },
720721

721722
{ { mpe::SoundId::Block, { mpe::SoundSubCategory::Wooden,
722-
mpe::SoundSubCategory::Temple } }, { midi::Program(128, 0) } },
723+
mpe::SoundSubCategory::Temple } }, { midi::Program(1, 115) } },
723724
{ { mpe::SoundId::Block, { mpe::SoundSubCategory::Wooden } }, { midi::Program(128, 0) } },
724725
{ { mpe::SoundId::Block, { mpe::SoundSubCategory::Sandpaper } }, { midi::Program(128, 0) } },
725726

@@ -734,6 +735,7 @@ static const auto& mappingByCategory(const mpe::SoundCategory category)
734735
{ { mpe::SoundId::Tubo, {} }, { midi::Program(128, 48) } },
735736
{ { mpe::SoundId::Vibraslap, {} }, { midi::Program(128, 0) } },
736737
{ { mpe::SoundId::Whip, {} }, { midi::Program(128, 56) } },
738+
{ { mpe::SoundId::Cannon, {} }, { midi::Program(0, 127) } },
737739

738740
{ { mpe::SoundId::Drum, { mpe::SoundSubCategory::Marching,
739741
mpe::SoundSubCategory::Snare } }, { midi::Program(128, 56) } },

framework/audio/internal/worker/clock.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ void Clock::forward(const msecs_t nextMsecs)
4242
return;
4343
}
4444

45+
if (m_countDown > nextMsecs) {
46+
m_countDown -= nextMsecs;
47+
return;
48+
} else if (m_countDown != 0) {
49+
m_countDown = 0;
50+
m_countDownEnded.notify();
51+
}
52+
4553
msecs_t newTime = m_currentTime + nextMsecs;
4654

4755
if (m_timeLoopStart < m_timeLoopEnd && newTime >= m_timeLoopEnd) {
@@ -80,12 +88,14 @@ void Clock::reset()
8088
{
8189
seek(0);
8290
resetTimeLoop();
91+
m_countDown = 0;
8392
}
8493

8594
void Clock::stop()
8695
{
8796
m_status.set(PlaybackStatus::Stopped);
8897
seek(0);
98+
m_countDown = 0;
8999
}
90100

91101
void Clock::pause()
@@ -137,6 +147,16 @@ void Clock::resetTimeLoop()
137147
m_timeLoopEnd = 0;
138148
}
139149

150+
void Clock::setCountDown(const msecs_t duration)
151+
{
152+
m_countDown = duration;
153+
}
154+
155+
async::Notification Clock::countDownEnded() const
156+
{
157+
return m_countDownEnded;
158+
}
159+
140160
bool Clock::isRunning() const
141161
{
142162
return m_status.val == PlaybackStatus::Running;

framework/audio/internal/worker/clock.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class Clock : public IClock, public async::Asyncable
5252
Ret setTimeLoop(const msecs_t fromMsec, const msecs_t toMsec) override;
5353
void resetTimeLoop() override;
5454

55+
void setCountDown(const msecs_t duration) override;
56+
async::Notification countDownEnded() const override;
57+
5558
msecs_t currentTime() const override;
5659
async::Channel<secs_t> timeChanged() const override;
5760

@@ -63,9 +66,11 @@ class Clock : public IClock, public async::Asyncable
6366
msecs_t m_timeDuration = 0;
6467
msecs_t m_timeLoopStart = 0;
6568
msecs_t m_timeLoopEnd = 0;
69+
msecs_t m_countDown = 0;
6670

6771
async::Channel<secs_t> m_timeChangedInSecs;
6872
async::Notification m_seekOccurred;
73+
async::Notification m_countDownEnded;
6974
};
7075
}
7176

framework/audio/internal/worker/eventaudiosource.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ void EventAudioSource::seek(const msecs_t newPositionMsecs)
138138
m_synth->revokePlayingNotes();
139139
}
140140

141+
void EventAudioSource::flush()
142+
{
143+
ONLY_AUDIO_WORKER_THREAD;
144+
145+
IF_ASSERT_FAILED(m_synth) {
146+
return;
147+
}
148+
149+
m_synth->flushSound();
150+
}
151+
141152
const AudioInputParams& EventAudioSource::inputParams() const
142153
{
143154
return m_params;

framework/audio/internal/worker/eventaudiosource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class EventAudioSource : public ITrackAudioInput, public muse::Injectable, publi
5353
samples_t process(float* buffer, samples_t samplesPerChannel) override;
5454

5555
void seek(const msecs_t newPositionMsecs) override;
56+
void flush() override;
5657

5758
const AudioInputParams& inputParams() const override;
5859
void applyInputParams(const AudioInputParams& requiredParams) override;

framework/audio/internal/worker/iclock.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class IClock
5858
virtual Ret setTimeLoop(const msecs_t fromMsec, const msecs_t toMsec) = 0;
5959
virtual void resetTimeLoop() = 0;
6060

61+
virtual void setCountDown(const msecs_t duration) = 0;
62+
virtual async::Notification countDownEnded() const = 0;
63+
6164
virtual async::Channel<secs_t> timeChanged() const = 0;
6265
};
6366

framework/audio/internal/worker/isequenceplayer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class ISequencePlayer
3434
public:
3535
virtual ~ISequencePlayer() = default;
3636

37-
virtual void play() = 0;
37+
virtual void play(const secs_t delay = 0) = 0;
3838
virtual void seek(const secs_t newPosition) = 0;
3939
virtual void stop() = 0;
4040
virtual void pause() = 0;
41-
virtual void resume() = 0;
41+
virtual void resume(const secs_t delay = 0) = 0;
4242

4343
virtual PlaybackStatus playbackStatus() const = 0;
4444
virtual async::Channel<PlaybackStatus> playbackStatusChanged() const = 0;

framework/audio/internal/worker/player.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ TrackSequenceId Player::sequenceId() const
8888
return m_sequenceId;
8989
}
9090

91-
void Player::play()
91+
void Player::play(const secs_t delay)
9292
{
9393
ONLY_AUDIO_MAIN_THREAD;
9494

95-
Async::call(this, [this]() {
95+
Async::call(this, [this, delay]() {
9696
ONLY_AUDIO_WORKER_THREAD;
9797
ITrackSequencePtr s = seq();
9898
if (s) {
99-
s->player()->play();
99+
s->player()->play(delay);
100100
}
101101
}, AudioThread::ID);
102102
}
@@ -140,15 +140,15 @@ void Player::pause()
140140
}, AudioThread::ID);
141141
}
142142

143-
void Player::resume()
143+
void Player::resume(const secs_t delay)
144144
{
145145
ONLY_AUDIO_MAIN_THREAD;
146146

147-
Async::call(this, [this]() {
147+
Async::call(this, [this, delay]() {
148148
ONLY_AUDIO_WORKER_THREAD;
149149
ITrackSequencePtr s = seq();
150150
if (s) {
151-
s->player()->resume();
151+
s->player()->resume(delay);
152152
}
153153
}, AudioThread::ID);
154154
}

framework/audio/internal/worker/player.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class Player : public IPlayer, public async::Asyncable
3838

3939
TrackSequenceId sequenceId() const override;
4040

41-
void play() override;
41+
void play(const secs_t delay = 0) override;
4242
void seek(const secs_t newPosition) override;
4343
void stop() override;
4444
void pause() override;
45-
void resume() override;
45+
void resume(const secs_t delay = 0) override;
4646

4747
PlaybackStatus playbackStatus() const override;
4848
async::Channel<PlaybackStatus> playbackStatusChanged() const override;

0 commit comments

Comments
 (0)