generated from 219-design/qt-qml-project-template-with-ci
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init fluidsynth on app launch and play test note
- Loading branch information
1 parent
9fd8c65
commit b99677c
Showing
16 changed files
with
266 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../fsynth/gcc_64/usr/local/lib64/libfluidsynth.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../fsynth/gcc_64/usr/local/lib64/libfluidsynth.so.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
QMAKE_CXXFLAGS += -isystem $${top_builddir}/fsynth/gcc_64/usr/local/include | ||
|
||
!include(fluidsynth_linkonly.pri) { error() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
# This 'pri' file can be used by the executable, which needs to link against | ||
# fluidsynth but NOT be able to 'see' the header files. | ||
# | ||
# In other words, here we put libfluidsynth on linker path but >NOT< include path! | ||
|
||
LIBS += -L$${top_builddir}/fsynth/gcc_64/usr/local/lib64 -lfluidsynth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#include "fsynth.h" | ||
|
||
#include <QDebug> | ||
|
||
#include <fluidsynth.h> | ||
#include <fluidsynth/version.h> | ||
|
||
#include <stdlib.h> | ||
|
||
#include "util-assert.h" | ||
|
||
namespace heory | ||
{ | ||
namespace | ||
{ | ||
bool IsRunningOnGithubRuner() | ||
{ | ||
if( getenv( "GITHUB_ACTIONS" ) ) | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} | ||
} // namespace | ||
|
||
struct FsynthWrapper::Impl | ||
{ | ||
Impl() | ||
: test_lacking_alsa( IsRunningOnGithubRuner() ) | ||
{ | ||
} | ||
|
||
const bool test_lacking_alsa; | ||
fluid_settings_t* settings = nullptr; | ||
fluid_synth_t* synth = nullptr; | ||
fluid_midi_router_t* router = nullptr; | ||
fluid_midi_driver_t* mdriver = nullptr; | ||
fluid_audio_driver_t* adriver = nullptr; | ||
}; | ||
|
||
FsynthWrapper::FsynthWrapper( const CliOptions& /*options*/ ) | ||
: m_i( new Impl ) | ||
{ | ||
m_i->settings = new_fluid_settings(); | ||
FASSERT( m_i->settings, "must be non-null" ); | ||
|
||
fluid_settings_setstr( m_i->settings, "audio.driver", "pulseaudio" ); | ||
fluid_settings_setstr( m_i->settings, "midi.driver", "alsa_seq" ); | ||
fluid_settings_setint( m_i->settings, "midi.autoconnect", 1 ); | ||
fluid_settings_setnum( m_i->settings, "synth.gain", 1 ); | ||
|
||
m_i->synth = new_fluid_synth( m_i->settings ); | ||
FASSERT( m_i->synth, "must be non-null" ); | ||
|
||
// dpkg-query -L fluid-soundfont-gm # find where 'sf2' sound fonts were installed | ||
const int sf = fluid_synth_sfload( m_i->synth, "/usr/share/sounds/sf2/FluidR3_GM.sf2", /*reset_presets*/ 1 ); | ||
FASSERT( sf != FLUID_FAILED, "failed call to fluid_synth_sfload" ); | ||
qDebug() << "fluid_synth_sfload returned sf id:" << sf; | ||
|
||
if( !m_i->test_lacking_alsa ) | ||
{ | ||
// fluidsynth: debug: Using 'alsa_seq' midi driver | ||
// ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory | ||
// fluidsynth: error: Error opening ALSA sequencer | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
m_i->router = new_fluid_midi_router( | ||
m_i->settings, | ||
fluid_midi_dump_postrouter, | ||
static_cast<void*>( m_i->synth ) ); | ||
FASSERT( m_i->router, "must be non-null" ); | ||
|
||
// In dump mode, text output is generated for events going into and out of | ||
// the router. The example dump functions are put into the chain before and | ||
// after the router. | ||
m_i->mdriver = new_fluid_midi_driver( | ||
m_i->settings, | ||
fluid_midi_dump_prerouter, | ||
static_cast<void*>( m_i->router ) ); | ||
FASSERT( m_i->mdriver, "must be non-null" ); | ||
|
||
m_i->adriver = new_fluid_audio_driver( m_i->settings, m_i->synth ); | ||
FASSERT( m_i->adriver, "must be non-null" ); | ||
|
||
const int note = fluid_synth_noteon( m_i->synth, 0 /*chan*/, 60 /*key*/, 100 /*velocity*/ ); | ||
FASSERT( note == FLUID_OK, "failed in fluid_synth_noteon" ); | ||
} | ||
} | ||
|
||
FsynthWrapper::~FsynthWrapper() | ||
{ | ||
delete m_i; | ||
} | ||
|
||
} // namespace heory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Copyright (c) 2020, pestophagous (pestophagous@users.noreply.github.com) | ||
// See LICENSE.txt | ||
// | ||
// https://github.com/pestophagous/ | ||
// | ||
#ifndef PROJECT_LIB_FSYNTH_H | ||
#define PROJECT_LIB_FSYNTH_H | ||
|
||
namespace heory | ||
{ | ||
class CliOptions; | ||
|
||
class FsynthWrapper | ||
{ | ||
public: | ||
explicit FsynthWrapper( const CliOptions& options ); | ||
~FsynthWrapper(); | ||
|
||
FsynthWrapper( const FsynthWrapper& ) = delete; | ||
FsynthWrapper& operator=( const FsynthWrapper& ) = delete; | ||
|
||
private: | ||
struct Impl; | ||
Impl* const m_i; | ||
}; | ||
|
||
} // namespace heory | ||
|
||
#endif // PROJECT_LIB_FSYNTH_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "music_notes.h" | ||
|
||
#include <QDebug> | ||
|
||
#include "src/lib/fsynth.h" | ||
#include "util-assert.h" | ||
|
||
namespace heory | ||
{ | ||
MusicNotes::MusicNotes( FsynthWrapper* fsynth ) | ||
: m_fsynth( fsynth ) | ||
{ | ||
} | ||
|
||
MusicNotes::~MusicNotes() = default; | ||
|
||
void MusicNotes::ExportContextPropertiesToQml( QQmlEngine* engine ) | ||
{ | ||
(void) engine; | ||
} | ||
|
||
} // namespace heory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Copyright (c) 2020, pestophagous (pestophagous@users.noreply.github.com) | ||
// See LICENSE.txt | ||
// | ||
// https://github.com/pestophagous/ | ||
// | ||
#ifndef PROJECT_LIB_MUSIC_NOTES_H | ||
#define PROJECT_LIB_MUSIC_NOTES_H | ||
|
||
#include <QtCore/QObject> | ||
#include <QtQml/QQmlEngine> | ||
|
||
#include <memory> | ||
|
||
namespace heory | ||
{ | ||
class FsynthWrapper; | ||
|
||
class MusicNotes : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
// clang-format off | ||
|
||
// Q_PROPERTY( QString | ||
// READ | ||
// NOTIFY ) | ||
// clang-format on | ||
|
||
public: | ||
explicit MusicNotes( FsynthWrapper* fsynth ); | ||
~MusicNotes() override; | ||
|
||
MusicNotes( const MusicNotes& ) = delete; | ||
MusicNotes& operator=( const MusicNotes& ) = delete; | ||
|
||
void ExportContextPropertiesToQml( QQmlEngine* engine ); | ||
|
||
private: | ||
FsynthWrapper* const m_fsynth; | ||
}; | ||
|
||
} // namespace heory | ||
|
||
#endif // PROJECT_LIB_MUSIC_NOTES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ | ||
|
||
cat << EOF > $HOME/.asoundrc | ||
pcm.dummy { | ||
type hw | ||
card 0 | ||
} | ||
ctl.dummy { | ||
type hw | ||
card 0 | ||
} | ||
EOF | ||
chmod go+r $HOME/.asoundrc | ||
|
||
sudo bash -c 'cat << EOF >> /etc/modules.conf | ||
# OSS/Free portion - card #1 | ||
alias sound-slot-0 snd-card-0 | ||
alias sound-service-0-0 snd-mixer-oss | ||
alias sound-service-0-1 snd-seq-oss | ||
alias sound-service-0-3 snd-pcm-oss | ||
alias sound-service-0-8 snd-seq-oss | ||
alias sound-service-0-12 snd-pcm-oss | ||
EOF' | ||
sudo modprobe snd-dummy || true # not working (as of Apr 5, 2020) | ||
sudo modprobe snd-seq || true # not working (as of Apr 5, 2020) | ||
find /lib/modules/ # no snd modules present (as of Apr 5, 2020) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TODO. Figure out how to get these lines to succeed in github ci.