Piping audio into RSCW

In my spare time, I’m still playing around with RSCW, the Morse code decoder program. One of the hurdles that I’ve finally overcome (Praise God!) was how to send sound to the decoder. It turns out to be pretty simple, it just took me a few tries to get it right.

You see, by default, RSCW has several examples and options for sound input. Since it is an older program, it was written back when Linux kernel still used /dev/dsp and /dev/audio, back when everyone was using OSS and only a few had switched to ALSA sound. I don’t think PulseAudio was even a thing, yet…. It could also use input from programs such as sox, converting wave files to raw sound data, or use it’s own noise and CW generator.

Obviously, it would not be practical to record audio and then use sox to convert it and send it over to RSCW, nor would it be helpful to generate my own Morse code with the noise program, since I want to get live feeds from my HAM radio. I don’t want to downgrade my Linux kernel or OS to go back to the old method of sound card control, and to be honest, I’m not sure I really could without wiping my current setup.

Fortunately, there was a much simpler answer: arecord. Arecord is a “command-line sound recorder and player for ALSA soundcard driver”. In essence, it allows you to create recordings of anything being played or input into your sound system from the command line. The great thing is, as it has command line support, I can actually pipe it directly into RSCW rather than record the audio.

So, as a test, I jumped onto Morsecode.world’s translator page, which can generate Morse code from your input, and pasted information from the PulseAudio Wikipedia into the text field. This started playing Morse code over my speakers, to which I then used arecord to pipe to RSCW! Here was the output:

alaskalinuxuser@alaskalinuxuser-OptiPlex-790:/etc$ arecord | rscw -w 20 --track
RSCW 20 wpm mode track 1 - 3999 Hz ( rscw -h for help)
Recording WAVE 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono

The command is pretty basic:

arecord | rscw -w 20 --track

Of course there are more options that you could use, for both arecord or RSCW. Of interest is that you can use arecord to send just one specific input/output rather than everything or the default. You can list the available options with arecord -L:

alaskalinuxuser@alaskalinuxuser-OptiPlex-790:/etc$ arecord -L
Playback/recording through the PulseAudio sound server
Discard all samples (playback) or generate zero samples (capture)
PulseAudio Sound Server
HDA Intel PCH, ALC269VB Analog
Default Audio Device
HDA Intel PCH, ALC269VB Analog
Front speakers
HDA Intel PCH, ALC269VB Analog
Direct sample mixing device
HDA Intel PCH, ALC269VB Analog
Direct sample snooping device
HDA Intel PCH, ALC269VB Analog
Direct hardware device without any conversions
HDA Intel PCH, ALC269VB Analog
Hardware device with all software conversions

Now that I can accept input, now I just need to play around some more and see what I can do for speed settings for RSCW. It currently requires that you choose a speed, as it is not programmed to detect the speed of the signal. A Telegram user told me I should try “Fldigi”, so I’m going to take a look at that as well.

Linux – keep it simple.

Setting up the sound on my Linux phone.

To be honest, it doesn’t sound like something that should be very complicated, but it is. These days, with pulseaudio, you can usually have your sound system set up for you right out of the box. When you are using Linux that is expanded on your Android phone however, things tend to get a little bit complicated.

First, the stats:
Omnirom (equivalent to Android 4.4.4)
Debian Jessie 8.1
Samsung Captivate Glide

For some reason, to which I am still trying to figure out, dbus has some serious issues with Android. Pulseaudio appears to rely on dbus. Hence, no dbus, no pulseaudio. I have installed dbus, but it doesn’t appear to be doing the job it is supposed to do. Looking for a shorter route to working sound, I simply installed all of the Alsa tools.

$ sudo apt-get install alsa-base alsa-tools alsa-tools-gui alsa-utils alsaplayer-alsa alsaplayer-text

Per the Debian wiki, I needed to run the init to get it all configured.

$ sudo alsactl init

And presto! I have sound working, right? Well, not quite. I now had two distinct problems:
#1 – Sound only works for the root user.
#2 – Sound works once, then turns off after playing the sound.

As for the first problem, that is fairly standard and should be easily overcome. I added my user to the audio group, which should give me access to play sounds.

$ sudo adduser trondroid audio

Unfortunately, while adding me to group 29, the audio group, it did not give me permissions for sound. So I added my user to pulse, then pulse-access, etc. Each time, you need to log out and back in, of course to get the new group permissions. Finally, I added my user to root, but still no luck. I can only play sounds as the root user, or with the sudo command. So sudo it is.

As for the second problem, I haven’t figured that out yet either. I was using mocp, a command line media player, to play an mp3 song. No sound came out. When I open up the alsamixer, however, I can adjust the playback to an output, like the headphones, or the speakers. Once I do that, the sound plays. After I quit mocp, though, and try to play some other sound, once again it doesn’t play. I believe that this is Android’s fault. I think that the Android system is trying to conserve power or maintain control by shutting down “rogue” sound systems that are on by muting the outputs when not actually in use. This is probably a great feature for a phone, but is murder on my Linux setup.

Currently, to use the sound natively through Linux, I now have to sudo alsamixer to or sudo alsactl to set the sound device to the appropriate volume and make it ready for playback, I then need to immediately start my sound program with the sudo command to ensure that I have permission to play it. Fortunately, there are such things as scripts, so I can simply set it up and forget about it. Ultimately I plan to figure this out, I just need to take it one step at a time. Right now I’m just glad that I can make the sound work at all!

Linux – keep it simple.