新增当暂停时发送midi note all stop事件
This commit is contained in:
parent
fc15987207
commit
bcfcb91cca
@ -13,7 +13,7 @@ IMPL_SINGLETON_INSTANCE(midi_sequencer)
|
||||
|
||||
|
||||
void midi_sequencer::test() {
|
||||
const char* path = R"(F:\VST\VST64\4Front Piano x64.dll)";
|
||||
const char* path = R"(F:\VST\VST64\Serum_x64.dll)";
|
||||
// host->try_open_editor();
|
||||
|
||||
smf::MidiFile midifile("E:/Projects/AronaStudio/Arona/resources/1.mid");
|
||||
@ -21,7 +21,7 @@ void midi_sequencer::test() {
|
||||
spdlog::critical("Error reading MIDI file");
|
||||
midifile.doTimeAnalysis();
|
||||
midifile.linkNotePairs();
|
||||
midifile.joinTracks();
|
||||
// midifile.joinTracks();
|
||||
auto c = get_midi_sequencer()->create_clip<midi_clip>();
|
||||
auto track_count = midifile.getTrackCount();
|
||||
for (int i = 0; i < track_count; ++i) {
|
||||
@ -45,7 +45,7 @@ void midi_sequencer::init(singleton_initliazer& initliazer) {
|
||||
singleton_t::init(initliazer);
|
||||
auto adm = initliazer.require<audio_device_manager>();
|
||||
adm->on_sample_rate_changed.add_raw(this, &midi_sequencer::on_sample_rate_changed);
|
||||
set_bpm(140.0);
|
||||
set_bpm(200.0);
|
||||
}
|
||||
|
||||
void midi_sequencer::process(double sample_rate, uint32_t delta_frames) {
|
||||
@ -59,6 +59,17 @@ void midi_sequencer::process(double sample_rate, uint32_t delta_frames) {
|
||||
update_vst2_time_info();
|
||||
}
|
||||
|
||||
auto midi_sequencer::toggle_play() -> bool {
|
||||
playing_ = !playing_;
|
||||
if (!playing_) {
|
||||
auto instruments = g_plugin_host_manager.get_instrument_hosts();
|
||||
for (auto instrument : instruments) {
|
||||
instrument->push_stop_all_notes();
|
||||
}
|
||||
}
|
||||
return playing_;
|
||||
}
|
||||
|
||||
auto midi_sequencer::create_clip_instance(clip* clip) -> clip_instance* {
|
||||
auto instance = new clip_instance(clip);
|
||||
clip_instances_.push_back(instance);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
#include "misc/tick.h"
|
||||
@ -14,10 +15,7 @@ public:
|
||||
|
||||
void init(singleton_initliazer& initliazer) override;
|
||||
void process(double sample_rate, uint32_t delta_frames);
|
||||
auto toggle_play() -> bool {
|
||||
playing_ = !playing_;
|
||||
return playing_;
|
||||
}
|
||||
auto toggle_play() -> bool ;
|
||||
|
||||
template<class T>
|
||||
auto create_clip() -> T* {
|
||||
@ -44,7 +42,7 @@ protected:
|
||||
private:
|
||||
void update_vst2_time_info();
|
||||
|
||||
bool playing_ = false;
|
||||
std::atomic<bool> playing_ = false;
|
||||
double bpm_ = 0;
|
||||
double sample_pos_ = 0;
|
||||
int32_t tpq_pos_ = 0;
|
||||
|
@ -24,6 +24,11 @@ void plugin_host::on_update_buffer_size(int buffer_size)
|
||||
}
|
||||
}
|
||||
|
||||
void plugin_host::push_stop_all_notes(uint32_t frame_delta) {
|
||||
smf::MidiEvent event(0xB0, 0x7B, 0x00);
|
||||
push_midi(event, frame_delta);
|
||||
}
|
||||
|
||||
void plugin_host::try_open_editor() {
|
||||
if (!has_editor())
|
||||
return;
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
|
||||
virtual void process(uint32_t frame_num) = 0;
|
||||
virtual void push_midi(const smf::MidiEvent& event, uint32_t frame_delta) = 0;
|
||||
void push_stop_all_notes(uint32_t frame_delta = 0);
|
||||
|
||||
void try_open_editor();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user