Take SELCAL code as command arg
This commit is contained in:
parent
1188afaf4b
commit
2f1b5018a6
34
src/main.cpp
34
src/main.cpp
@ -10,7 +10,7 @@
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
SELCAL::Code code{"A5-CD"};
|
||||
SELCAL::Code code{argv[1]};
|
||||
|
||||
for (auto& group : code.getGroups()) {
|
||||
std::cout
|
||||
@ -21,17 +21,22 @@ int main(int argc, char** argv) {
|
||||
|
||||
|
||||
Synth synth;
|
||||
synth.loadSoundfont("../soundfonts/square-equaltemperament.sf2");
|
||||
//synth.loadSoundfont("../soundfonts/TimGM6mb.sf2");
|
||||
synth.loadSoundfont("../soundfonts/GU-1.471.sf2");
|
||||
|
||||
/*
|
||||
for(int i = 1; i < argc; ++i) {
|
||||
synth.loadSoundfont(argv[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
for (const Synth::Program& program : synth.getPrograms()) {
|
||||
std::cout << program.name << " " << program.soundfontId
|
||||
<< ":(" << program.bankNumber << ", " << program.programNumber << ")"
|
||||
<< std::endl;
|
||||
|
||||
if (program.name == "Square Wave") {
|
||||
if (program.name == "Night Vision") {
|
||||
std::cout << "Loading program!" << std::endl;
|
||||
synth.loadProgram(program);
|
||||
}
|
||||
@ -83,12 +88,6 @@ int main(int argc, char** argv) {
|
||||
constexpr double MIDI_CENT_SCALE = 100.0;
|
||||
const int keyIndex = static_cast<int>(pair.first);
|
||||
tunings[keyIndex] = frequencyToMidi(pair.second) * MIDI_CENT_SCALE;
|
||||
|
||||
std::cout
|
||||
<< magic_enum::enum_name(pair.first) << " = "
|
||||
<< pair.second << " Hz "
|
||||
<< " or MIDI key " << frequencyToMidi(pair.second) * MIDI_CENT_SCALE
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
fluid_synth_t* raw_synth = synth.getSynth();
|
||||
@ -101,8 +100,8 @@ int main(int argc, char** argv) {
|
||||
std::cout << "Set tuning: " << (success ? "success" : "failed") << std::endl;
|
||||
|
||||
for (auto& group : code.getGroups()) {
|
||||
fluid_synth_noteon(raw_synth, 0, static_cast<int>(group[0]), 100);
|
||||
fluid_synth_noteon(raw_synth, 1, static_cast<int>(group[1]), 100);
|
||||
fluid_synth_noteon(raw_synth, 0, static_cast<int>(group[0]), 127);
|
||||
fluid_synth_noteon(raw_synth, 1, static_cast<int>(group[1]), 127);
|
||||
std::this_thread::sleep_for(1s);
|
||||
|
||||
// Silence between tone groups
|
||||
@ -110,18 +109,5 @@ int main(int argc, char** argv) {
|
||||
std::this_thread::sleep_for(200ms);
|
||||
}
|
||||
|
||||
/*
|
||||
success = synth.resetTuning();
|
||||
std::cout << "Set tuning: " << (success ? "success" : "failed") << std::endl;
|
||||
|
||||
for (auto& group : code.getGroups()) {
|
||||
fluid_synth_noteon(raw_synth, 0, static_cast<int>(group[0]), 100);
|
||||
fluid_synth_noteon(raw_synth, 1, static_cast<int>(group[1]), 100);
|
||||
std::this_thread::sleep_for(1s);
|
||||
|
||||
// Silence between tone groups
|
||||
fluid_synth_all_notes_off(raw_synth, ALL_CHANNELS);
|
||||
std::this_thread::sleep_for(200ms);
|
||||
}
|
||||
*/
|
||||
std::this_thread::sleep_for(500ms);
|
||||
}
|
||||
|
||||
@ -65,6 +65,7 @@ bool Synth::loadSoundfont(const std::string& filepath) {
|
||||
bool Synth::loadProgram(const Program& program) {
|
||||
// TODO JMT: fix this
|
||||
fluid_synth_program_select(synth, 0, program.soundfontId, program.bankNumber, program.programNumber);
|
||||
fluid_synth_program_select(synth, 1, program.soundfontId, program.bankNumber, program.programNumber);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user