hselasky / alsa-seq-server

Userspace ALSA MIDI sequencer server
3 stars 0 forks source link

Add support for ALSA sequencer queues #1

Closed yurivict closed 1 year ago

yurivict commented 1 year ago

This projects needs it.

hselasky commented 1 year ago

Hi,

There are no plans currently to implement the sequencer part. Feel free to work on it, though!

--HPS

hselasky commented 1 year ago

See: 1b0907f41a4ba84a3c14338f38528c203da55181 Please test and report back. There is no tag yet, so just compile directly from the repository.

yurivict commented 1 year ago

This is great!

I am not able to test at the moment because all programs fail to connect to PulseAudio for some reason on my system with "Connection refused".

hselasky commented 1 year ago

How to test:

fluidsynth -m alsa_seq

# and

drumstick-guiplayer -p 1:0 midi_file.mid

Needed to rebuild fluidsynth with ALSA support.

--HPS

hselasky commented 1 year ago

Please test when you get your pulseaudio issues resolved! Then I will make a new version and package for FreeBSD.

yurivict commented 1 year ago

When I run this setup:

fluidsynth -m alsa_seq -a oss -ni /usr/local/share/sounds/sf2/FluidR3_GS.sf2
# and
drumstick-guiplayer -p 1:0 midi_file.mid

fluidsynth prints this and exits:

$ fluidsynth -ni /usr/local/share/sounds/sf2/FluidR3_GS.sf2 -m alsa_seq -a oss
FluidSynth runtime version 2.2.8
Copyright (C) 2000-2022 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.

fluidsynth: warning: No preset found on channel 0 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 1 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 2 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 3 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 4 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 5 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 6 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 7 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 8 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 9 [bank=128 prog=0]
fluidsynth: warning: No preset found on channel 10 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 11 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 12 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 13 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 14 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 15 [bank=0 prog=0]
fluidsynth: warning: Failed to set thread to high priority
yurivict commented 1 year ago

Without -ni it also fails to play drumstick output:

$ fluidsynth  /usr/local/share/sounds/sf2/FluidR3_GS.sf2 -m alsa_seq -a oss
FluidSynth runtime version 2.2.8
Copyright (C) 2000-2022 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.

fluidsynth: warning: No preset found on channel 0 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 1 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 2 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 3 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 4 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 5 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 6 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 7 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 8 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 9 [bank=128 prog=0]
fluidsynth: warning: No preset found on channel 10 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 11 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 12 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 13 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 14 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 15 [bank=0 prog=0]
fluidsynth: warning: Failed to set thread to high priority
Type 'help' for help topics.

fluidsynth: warning: Failed to set thread to high priority
> fluidsynth: warning: No preset found on channel 0 [bank=0 prog=56]
fluidsynth: warning: No preset found on channel 1 [bank=0 prog=60]
fluidsynth: warning: No preset found on channel 5 [bank=0 prog=49]
fluidsynth: warning: No preset found on channel 6 [bank=0 prog=48]
fluidsynth: warning: No preset found on channel 2 [bank=0 prog=57]
fluidsynth: warning: No preset found on channel 8 [bank=0 prog=47]
fluidsynth: warning: No preset found on channel 4 [bank=0 prog=48]
fluidsynth: warning: No preset found on channel 7 [bank=0 prog=46]
fluidsynth: warning: No preset found on channel 3 [bank=0 prog=58]
fluidsynth: warning: No preset found on channel 10 [bank=0 prog=72]
hselasky commented 1 year ago

What is the output from:

aconnect -l

And what is the drumstick version?

hselasky commented 1 year ago

Maybe you need to change the value after -p for drumstick.

cederom commented 1 year ago

Hello world @hselasky and @yurivict :-)

My alsa-seq-server tests below:

octagon% uname -a
FreeBSD octagon 13.1-STABLE FreeBSD 13.1-STABLE #0 stable/13-n252019-158071c51a1: Mon Aug  1 01:14:44 CEST 2022     root@hexagon:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64

octagon% pwd
/XXX/alsa-seq-server.git
octagon% make
Warning: Object directory not changed from original /XXX/alsa-seq-server.git
cc  -O2 -pipe -I/usr/local/include -Wall -march=bdver2  -g -MD  -MF.depend.autodetect.o -MTautodetect.o -std=gnu99 -Wno-format-zero-length -nobuiltininc -idirafter /usr/lib/clang/11.0.1/include -fstack-protector-strong    -Qunused-arguments    -c autodetect.c -o autodetect.o
cc  -O2 -pipe -I/usr/local/include -Wall -march=bdver2  -g -MD  -MF.depend.alsa-seq-server.o -MTalsa-seq-server.o -std=gnu99 -Wno-format-zero-length -nobuiltininc -idirafter /usr/lib/clang/11.0.1/include -fstack-protector-strong    -Qunused-arguments    -c alsa-seq-server.c -o alsa-seq-server.o
cc  -O2 -pipe -I/usr/local/include -Wall -march=bdver2  -g -MD  -MF.depend.queue.o -MTqueue.o -std=gnu99 -Wno-format-zero-length -nobuiltininc -idirafter /usr/lib/clang/11.0.1/include -fstack-protector-strong    -Qunused-arguments    -c queue.c -o queue.o
cc -O2 -pipe -I/usr/local/include -Wall -march=bdver2 -g -std=gnu99 -Wno-format-zero-length -nobuiltininc -idirafter /usr/lib/clang/11.0.1/include -fstack-protector-strong -Qunused-arguments  -L/usr/local/lib -lpthread -lcuse   -o alsa-seq-server.full autodetect.o alsa-seq-server.o queue.o
objcopy --only-keep-debug alsa-seq-server.full alsa-seq-server.debug
objcopy --strip-debug --add-gnu-debuglink=alsa-seq-server.debug  alsa-seq-server.full alsa-seq-server

octagon% ./alsa-seq-server.full
alsa-seq-server.full: Could not connect to cuse module

octagon% kldstat | grep cuse
 3    1 0xffffffff82136000     bb10 cuse.ko

octagon% kldstat | grep midi
octagon% kldstat | grep alsa
octagon% kldstat | grep snd
42    1 0xffffffff835f2000     e538 snd_uaudio.ko

octagon% cat /dev/sndstat
Installed devices:
pcm0: <EMU10Kx DSP front PCM interface> (play/rec) default
pcm1: <EMU10Kx DSP rear PCM interface> (play)
pcm2: <EMU10Kx DSP center PCM interface> (play)
pcm3: <EMU10Kx DSP subwoofer PCM interface> (play)
pcm4: <EMU10Kx DSP side PCM interface> (play)
pcm5: <ATI R6xx (HDMI)> (play)
pcm6: <ATI R6xx (HDMI)> (play)
pcm7: <ATI R6xx (HDMI)> (play)
pcm8: <ATI R6xx (HDMI)> (play)
pcm9: <ATI R6xx (HDMI)> (play)
pcm10: <ATI R6xx (HDMI)> (play)
pcm11: <USB audio> (rec)
pcm12: <USB audio> (rec)
Installed devices from userspace:
pcm_bt_panasonic: <Virtual OSS> (play/rec)

fluidsynth has the same problem as @yurivict .. some environment setup missing? :-)

octagon% fluidsynth -m alsa_seq -a oss -ni /usr/local/share/sounds/sf2/FluidR3_GS.sf2
FluidSynth runtime version 2.2.8
Copyright (C) 2000-2022 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.

fluidsynth: warning: No preset found on channel 0 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 1 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 2 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 3 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 4 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 5 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 6 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 7 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 8 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 9 [bank=128 prog=0]
fluidsynth: warning: No preset found on channel 10 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 11 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 12 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 13 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 14 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 15 [bank=0 prog=0]
fluidsynth: warning: Failed to set thread to high priority

Update1: I have built alsa_seq_server and installed as root, does not seem to be a known service (I am building from master)?

# make all install
Warning: Object directory not changed from original /XXX/alsa-seq-server.git
cc  -O2 -pipe -I/usr/local/include -Wall -march=bdver2  -g -MD  -MF.depend.autodetect.o -MTautodetect.o -std=gnu99 -Wno-format-zero-length -nobuiltininc -idirafter /usr/lib/clang/11.0.1/include -fstack-protector-strong    -Qunused-arguments    -c autodetect.c -o autodetect.o
cc  -O2 -pipe -I/usr/local/include -Wall -march=bdver2  -g -MD  -MF.depend.alsa-seq-server.o -MTalsa-seq-server.o -std=gnu99 -Wno-format-zero-length -nobuiltininc -idirafter /usr/lib/clang/11.0.1/include -fstack-protector-strong    -Qunused-arguments    -c alsa-seq-server.c -o alsa-seq-server.o
cc  -O2 -pipe -I/usr/local/include -Wall -march=bdver2  -g -MD  -MF.depend.queue.o -MTqueue.o -std=gnu99 -Wno-format-zero-length -nobuiltininc -idirafter /usr/lib/clang/11.0.1/include -fstack-protector-strong    -Qunused-arguments    -c queue.c -o queue.o
cc -O2 -pipe -I/usr/local/include -Wall -march=bdver2 -g -std=gnu99 -Wno-format-zero-length -nobuiltininc -idirafter /usr/lib/clang/11.0.1/include -fstack-protector-strong -Qunused-arguments  -L/usr/local/lib -lpthread -lcuse   -o alsa-seq-server.full autodetect.o alsa-seq-server.o queue.o
objcopy --only-keep-debug alsa-seq-server.full alsa-seq-server.debug
objcopy --strip-debug --add-gnu-debuglink=alsa-seq-server.debug  alsa-seq-server.full alsa-seq-server
install  -s -o root -g wheel -m 555   alsa-seq-server /usr/local/sbin/alsa-seq-server
install  -d /usr/local/sbin/.debug/
install  -o root -g wheel -m 444  alsa-seq-server.debug /usr/local/sbin/.debug/alsa-seq-server.debug

# service alsa_seq_server restart
alsa_seq_server does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable

# service alsa_seq_server onerestart
alsa_seq_server does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable
hselasky commented 1 year ago

Try this instead:

fluidsynth -m alsa_seq -a oss /usr/local/share/sounds/sf2/FluidR3_GM.sf2

hselasky commented 1 year ago

@cederom : The sequencer server must be run as root :-)

yurivict commented 1 year ago

This works: fluidsynth -m alsa_seq -a oss /usr/local/share/sounds/sf2/FluidR3_GM.sf2 *.mid file is playing.

hselasky commented 1 year ago

@cederom : Install the port first!

ls /usr/local/etc/rc.d/alsa_seq_server

cederom commented 1 year ago

@cederom : The sequencer server must be run as root :-)

OMG! It works now :-) But it does not react to ^C and kill o_O (Update: it reacts to ^C with a long delay).

I have installed drumstick but there is no drumstick-guiplayer only drumstick-vpiano and it plays some notes no matter if fluidsynth is active of not :-)

cederom commented 1 year ago

@cederom : Install the port first!

ls /usr/local/etc/rc.d/alsa_seq_server

Done :-) Sorry :-)

Update1: Built from ports, service started. Now local build gives me this:

# ./alsa-seq-server.full
alsa-seq-server.full: Could not create '/dev/snd/seq'

Note: I am using PulseAudio as my primary audio backend is this a problem? :-P

Update2: I have installed dmidiplayer and it plays a midi file DESCE039.MID.zip :-) Sound goes from my main speakers not from my headphones that are set as default in PA so probably it playes over ALSA?

hselasky commented 1 year ago
# ./alsa-seq-server.full
alsa-seq-server.full: Could not create '/dev/snd/seq'

This means the sequencer server is running. Please close all clients before restarting the server :-)

You need to get latest drumstick port:

drumstick-2.7.1_2 MIDI libraries for Qt/C++

hselasky commented 1 year ago

Real music, see below :-)

You can also build zynaddsubfx with ALSA support and use:

zynaddsubfx -I ALSA -O OSS -r 48000

hps_jam_037_002.mid.zip

cederom commented 1 year ago

Real music, see below :-)

You can also build zynaddsubfx with ALSA support and use:

zynaddsubfx -I ALSA -O OSS -r 48000

hps_jam_037_002.mid.zip

Cool :-) I made it work :-) Jumped into the deep water of configurations but it works! Congratz!! :-)

What I did:

ps/2: I have to update my stable/13-n252019-158071c51a1: Mon Aug 1 01:14:44 CEST 2022 because latest ports complains my system is unsupported? o_O

Update1: I made zynaddsubfx work! What a cool program :-) I will have to design and build a MIDI-USB interface as I still should have some keyboard around :-)

Update2: When fluidsynth is not present there is no sound but sequencer works. When alsa-seq-server is not present players report missing ALSA device/infrastructure. I guess that confirms valid ALSA operations :-)

CONGRATULATIONS @hselasky !! :-)

hselasky commented 1 year ago

Seems to work! Closing this issue for now:

https://cgit.freebsd.org/ports/commit/?id=3a57a5ea9a2d8a1397b6745ea55b14db7f21518b