qsynth as source

gotofourths

New Member
Hello,
I decided to use OBS on Ubuntu 22.4 to create piano tutorial videos . So far I used to do it with seperate tools. My first try was successful ı recorded with top and front cameras (droidcam) and for piano sound I used ardour separately recording MIDI and then converting the MIDI to audio finaly synchronizing it with the videos.

However, since running the two software together increases resource usage, there are skips in the videos. So I thought if i can record the piano MIDI sound with video on OBS, that would be great. I use qsynth to produce sound on pc with sound fonts . But I could not get the sound with any of the audio sources provided by OBS nor "Desktop Audios" . I am new on OBS and audio systems on Linux . Any ideas will be appreciated.
Thank you.
 

AaronD

Active Member
I use Ubuntu Studio - a creative and live-media centered version of Ubuntu - to run all of my rigs: a home studio, a hybrid local and remote meeting with a good recording to watch later, a streaming church service, and projection in a different church.

UStudio has JACK and a TON of other things preinstalled, so all I had to do was put them together. For the meeting rig, there's enough going on that I have a script to manage it, instead of starting and shutting down manually. Part of the script sets up the audio loopbacks to go between Ardour (DAW) and everything else:
Bash:
#
# Start Jack
#

echo
echo "Start Jack"
qjackctl &
PID_JACK=$!
sleep 5

#
# Create Bridges to/from PulseAudio
#

echo
echo "Create Bridges to/from PulseAudio"
INDEX_SINK_0=$(     pactl   load-module     module-jack-sink    channels=2    sink_name=PA_out_Playback     client_name=PA_out_Playback     )
INDEX_SINK_1=$(     pactl   load-module     module-jack-sink    channels=2    sink_name=PA_out_Meet_Rtrn    client_name=PA_out_Meet_Rtrn    )
INDEX_SOURCE_0=$(   pactl   load-module     module-jack-source  channels=2  source_name=PA_in_Mics          client_name=PA_in_Mics          )
INDEX_SOURCE_1=$(   pactl   load-module     module-jack-source  channels=2  source_name=PA_in_Meet_Send     client_name=PA_in_Meet_Send     )
INDEX_SOURCE_2=$(   pactl   load-module     module-jack-source  channels=2  source_name=PA_in_Record        client_name=PA_in_Record        )

#
# Remove Automatic Connections
#

disconnect_all ()
{
    for CONNECTION in $(jack_lsp --connections "$1")
    do
        if [[ "$CONNECTION" = "$1" ]]
        then
            continue
        fi
        jack_disconnect "$1" "$CONNECTION"
    done
}
disconnect_all system:capture_1
disconnect_all system:capture_2
disconnect_all system:playback_1
disconnect_all system:playback_2

#
# Save and Set Default Connections
#

PA_DEFAULT_SINK=$(      pactl   get-default-sink    )
PA_DEFAULT_SOURCE=$(    pactl   get-default-source  )
pactl   set-default-sink    PA_out_Playback
pactl   set-default-source  PA_in_Mics
  • QjackCtl is set to start and stop the server when it starts and stops, so after its sleep 5, I have JACK running, and the teardown code below really does put everything back to how it was before.
  • Then the script creates 5 named pipes between PulseAudio and JACK. The DAW connects to the JACK side, and OBS and the meeting connect to the PA side of each pipe.
  • Then there's some cleanup, and routing whatever else I might want to use to these new connections.
Once everything is set up, the script waits for me to tell it I'm done, and then tears the rig down too. The corresponding bit of code to the above is:
Bash:
#
# Restore Default Connections
#

echo
echo "Unload Bridges between Jack and PulseAudio"
pactl   set-default-sink    "$PA_DEFAULT_SINK"
pactl   set-default-source  "$PA_DEFAULT_SOURCE"

#
# Remove Bridges to/from PulseAudio
#

pactl unload-module $INDEX_SOURCE_2
pactl unload-module $INDEX_SOURCE_1
pactl unload-module $INDEX_SOURCE_0
pactl unload-module $INDEX_SINK_1
pactl unload-module $INDEX_SINK_0

#
# Stop Jack
#

echo
echo "Stop Jack"
kill -TERM "$PID_JACK"
sleep 1
In your case, I think you'd simply replace the DAW with Qsynth, and have maybe 1 bridge instead of 5, but otherwise keep the same structure.
 

AaronD

Active Member
All of that said though, Ubuntu 22.04 and its derivatives are falling out of support soon. If you want to continue receiving security patches (keep hackers out), then you'll need to update.

The latest LTS is 24.04, which I'm going to switch to sometime this month. It replaces both PulseAudio and JACK with PipeWire, which is a single thing that is supposed to emulate both and be easier to use. I'll find out how true or not that really is.
 

gotofourths

New Member
I use Ubuntu Studio - a creative and live-media centered version of Ubuntu - to run all of my rigs: a home studio, a hybrid local and remote meeting with a good recording to watch later, a streaming church service, and projection in a different church.

UStudio has JACK and a TON of other things preinstalled, so all I had to do was put them together. For the meeting rig, there's enough going on that I have a script to manage it, instead of starting and shutting down manually. Part of the script sets up the audio loopbacks to go between Ardour (DAW) and everything else:
Bash:
#
# Start Jack
#

echo
echo "Start Jack"
qjackctl &
PID_JACK=$!
sleep 5

#
# Create Bridges to/from PulseAudio
#

echo
echo "Create Bridges to/from PulseAudio"
INDEX_SINK_0=$(     pactl   load-module     module-jack-sink    channels=2    sink_name=PA_out_Playback     client_name=PA_out_Playback     )
INDEX_SINK_1=$(     pactl   load-module     module-jack-sink    channels=2    sink_name=PA_out_Meet_Rtrn    client_name=PA_out_Meet_Rtrn    )
INDEX_SOURCE_0=$(   pactl   load-module     module-jack-source  channels=2  source_name=PA_in_Mics          client_name=PA_in_Mics          )
INDEX_SOURCE_1=$(   pactl   load-module     module-jack-source  channels=2  source_name=PA_in_Meet_Send     client_name=PA_in_Meet_Send     )
INDEX_SOURCE_2=$(   pactl   load-module     module-jack-source  channels=2  source_name=PA_in_Record        client_name=PA_in_Record        )

#
# Remove Automatic Connections
#

disconnect_all ()
{
    for CONNECTION in $(jack_lsp --connections "$1")
    do
        if [[ "$CONNECTION" = "$1" ]]
        then
            continue
        fi
        jack_disconnect "$1" "$CONNECTION"
    done
}
disconnect_all system:capture_1
disconnect_all system:capture_2
disconnect_all system:playback_1
disconnect_all system:playback_2

#
# Save and Set Default Connections
#

PA_DEFAULT_SINK=$(      pactl   get-default-sink    )
PA_DEFAULT_SOURCE=$(    pactl   get-default-source  )
pactl   set-default-sink    PA_out_Playback
pactl   set-default-source  PA_in_Mics
  • QjackCtl is set to start and stop the server when it starts and stops, so after its sleep 5, I have JACK running, and the teardown code below really does put everything back to how it was before.
  • Then the script creates 5 named pipes between PulseAudio and JACK. The DAW connects to the JACK side, and OBS and the meeting connect to the PA side of each pipe.
  • Then there's some cleanup, and routing whatever else I might want to use to these new connections.
Once everything is set up, the script waits for me to tell it I'm done, and then tears the rig down too. The corresponding bit of code to the above is:
Bash:
#
# Restore Default Connections
#

echo
echo "Unload Bridges between Jack and PulseAudio"
pactl   set-default-sink    "$PA_DEFAULT_SINK"
pactl   set-default-source  "$PA_DEFAULT_SOURCE"

#
# Remove Bridges to/from PulseAudio
#

pactl unload-module $INDEX_SOURCE_2
pactl unload-module $INDEX_SOURCE_1
pactl unload-module $INDEX_SOURCE_0
pactl unload-module $INDEX_SINK_1
pactl unload-module $INDEX_SINK_0

#
# Stop Jack
#

echo
echo "Stop Jack"
kill -TERM "$PID_JACK"
sleep 1
In your case, I think you'd simply replace the DAW with Qsynth, and have maybe 1 bridge instead of 5, but otherwise keep the same structure.
Thank you very much your time and very helpful information. I use jack too and it helped me much. Your scripts are very helpful to manage Jack properly on DAW.
However I still think that I can do it with OBS's "desktop audio " mixer component. I could not get the sound of desktop. I think my problem is that. Because if i achieved this i can get the qsynth sound thru desktop and be able to record. Of course thats my current thought for now. As i mentioned before im new on this and my knowledge is like a garbage :) Thank you again.
 

gotofourths

New Member
Thank you very much your time and very helpful information. I use jack too and it helped me much. Your scripts are very helpful to manage Jack properly on DAW.
However I still think that I can do it with OBS's "desktop audio " mixer component. I could not get the sound of desktop. I think my problem is that. Because if i achieved this i can get the qsynth sound thru desktop and be able to record. Of course thats my current thought for now. As i mentioned before im new on this and my knowledge is like a garbage :) Thank you again.
LOL ! After replied to your message i tried again. And This time i could gt the desktop sound so Qsynth too ,i will compare the performans between working Ardour and working Qsynth . Hope last one will be better.
 
Top