Skip to content

Commit

Permalink
Update pipewire support
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhadeepJasu committed Jul 28, 2022
1 parent 867337f commit 32527a4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
Binary file modified data/Styles/StyleFiles/Rock@12_Bt_Pop_Rock.enstl
Binary file not shown.
Binary file modified data/Styles/rg/Rock@12_Bt_Pop_Rock.rg
Binary file not shown.
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ add_project_arguments (
'-D', 'ALSA_DRIVER',
'-D', 'PULSEAUDIO_DRIVER',
'-D', 'JACK_DRIVER',
# '-D', 'PIPEWIRE_CORE_DRIVER', # Uncomment to enable pipewire core support provided fluidsynth supports it
'-D', 'PIPEWIRE_CORE_DRIVER', # Uncomment to enable pipewire core support provided fluidsynth supports it
language: 'vala'
)

Expand All @@ -54,6 +54,7 @@ dependencies = [
dependency ('lv2'),
dependency ('lilv-0'),
dependency ('suil-0'),
dependency ('libpipewire-0.3', version: '>= 0.3.52'),
meson.get_compiler ('vala').find_library ('posix'),
meson.get_compiler ('c').find_library ('m', required : true),
meson.get_compiler ('c').find_library ('fluidsynth', required : true),
Expand Down
8 changes: 6 additions & 2 deletions src/Core/Synthesizer/Synthesizer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ namespace Ensembles.Core {
public int chord_type = 0;
public signal void detected_chord (int chord_main, int type);
public Synthesizer (string soundfont, string driver_name, double buffer_size) {
synthesizer_init (soundfont, driver_name, buffer_size);
bool use_pipewire = false;
#if PIPEWIRE_CORE_DRIVER
use_pipewire = true;
#endif
synthesizer_init (soundfont, driver_name, buffer_size, use_pipewire);
synthesizer_set_fx_callback ((buffer_l_in, buffer_r_in, out buffer_out_l, out buffer_out_r) => {
EffectRack.set_synth_callback (buffer_l_in, buffer_r_in, out buffer_out_l, out buffer_out_r);
});
Expand Down Expand Up @@ -192,7 +196,7 @@ namespace Ensembles.Core {
}

// synthesizer.c
extern void synthesizer_init (string loc, string dname, double buffer_size);
extern void synthesizer_init (string loc, string dname, double buffer_size, bool pw_enabled = false);
extern void synthesizer_destruct ();
extern int synthesizer_set_driver_configuration (string dname, double buffer_size);
extern int synthesizer_send_notes (int key, int on, int velocity, int channel, out int type);
Expand Down
12 changes: 7 additions & 5 deletions src/Core/Synthesizer/providers/synthesizer_instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ set_driver_configuration(const char* driver_name, double buffer_length_multiplie
fluid_settings_setnum(rendering_settings, "synth.overflow.percussion", 5000.0);
fluid_settings_setint(rendering_settings, "synth.midi-channels", 64);
fluid_settings_setstr(rendering_settings, "synth.midi-bank-select", "gs");
fluid_settings_setint(rendering_settings, "synth.polyphony", 512);
fluid_settings_setint(rendering_settings, "synth.polyphony", 1024);
}
if (utility_settings == NULL) {
utility_settings = new_fluid_settings ();
Expand Down Expand Up @@ -181,16 +181,18 @@ set_driver_configuration(const char* driver_name, double buffer_length_multiplie
}
if (strcmp (driver_name, "pipewire") == 0) {
fluid_settings_setstr(rendering_settings, "audio.driver", "pipewire");
fluid_settings_setint(rendering_settings, "audio.period-size", 64);
fluid_settings_setint(rendering_settings, "audio.pulseaudio.adjust-latency", 0);
fluid_settings_setint(rendering_settings, "audio.period-size", 512);
fluid_settings_setint(rendering_settings, "audio.pulseaudio.adjust-latency", 1);
fluid_settings_setstr(rendering_settings, "audio.pipewire.media-role", "Production");
fluid_settings_setstr(rendering_settings, "audio.pipewire.media-type", "Audio");
fluid_settings_setstr(rendering_settings, "audio.pipewire.media-category", "Playback");

fluid_settings_setstr(utility_settings, "audio.driver", "pipewire");
fluid_settings_setint(utility_settings, "audio.period-size", 64);
fluid_settings_setint(utility_settings, "audio.period-size", 256);
fluid_settings_setint(utility_settings, "audio.realtime-prio", 1);
fluid_settings_setstr(utility_settings, "audio.pipewire.media-role", "Production");
fluid_settings_setstr(utility_settings, "audio.pipewire.media-role", "DSP");
fluid_settings_setstr(utility_settings, "audio.pipewire.media-type", "Audio");
fluid_settings_setstr(utility_settings, "audio.pipewire.media-category", "Source");

return (int)(64.0 + (buffer_length_multiplier * 128.0));
}
Expand Down
6 changes: 5 additions & 1 deletion src/Core/Synthesizer/synthesizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ set_note_callback (synthesizer_note_event_callback callback) {
}

void
synthesizer_init(const char* loc, const char* dname, double buffer_size)
synthesizer_init(const char* loc, const char* dname, double buffer_size, __uint8_t pw_enabled)
{
if (pw_enabled)
{
pw_init(NULL, NULL);
}
set_driver_configuration(dname, buffer_size);
realtime_render_synth = get_synthesizer(RENDER);
if (fluid_is_soundfont(loc)) {
Expand Down
4 changes: 4 additions & 0 deletions vapi/libpipewire-0.3.vapi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[CCode(cheader_filename="pipewire/pipewire.h", lower_case_cprefix="pw_")]
namespace Pipewire {

}

0 comments on commit 32527a4

Please sign in to comment.