can hear MIDI but can't record it (reprise) [SOLVED]

Lubuntu 14.04
Audacity 2.0.5 (distributed version)
SoundBlaster Audigy 2 Value

I had this problem a while back when running MINT 14 and now I’m running Lubuntu it just cropped up again, so I went back to the old thread (https://forum.audacityteam.org/t/can-hear-midi-but-cant-record-it/31744/1) only to find that the fix/fiddle I applied before doesn’t work anymore.

To restate the problem : If I go into Audacity and hit the record button (to record “what I hear”), this works for music streaming or local sound files playing through a music player, but nothing is recorded when its a MIDI file playing (e.g. in a terminal session

aplaymidi -p 17:0 somefile.mid

I have tried playing around with pavucontrol and have tried all possible input device drop-down options within Audacity but no luck.

When the MIDI is playing, Pavucontrol shows no evidence of this as all (as if its being bypassed).

I am using the Soundcard as a midi renderer, loading a sound font via asfxload on bootup.

MIDI files can be rendered directly to WAV using Timidity++
Timidity++ can be used from the command line, or there are a couple of simple GUIs available for it.

Thanks - but I was only citing a midi file as an example. What I am really trying to do is listen to a midi being played through Scorch player (via Firefox/WINE - it won’t work outside Windows). The Scorch plugin player doesnt give me an option to save a midi file - I can only stream it. So I want to record it as a WAV under Audacity for ease of playback as the Scorch interface is very buggy.

The way that I record audio playing on the computer is to use the Pulse “monitor” device as described here: http://manual.audacityteam.org/o/man/tutorial_recording_computer_playback_on_linux.html

For that to work, the audio that is playing must be using PulseAudio for playback.
For applications running in Wine, you will need to configure Wine to use PulseAudio.

Thanks again.
I went to wine/configure wine and on the Audio tab set the output device to “pulseaudio” and restarted Firefox (under Wine). No change though :frowning: .

You can also connect a cable between audio out and line-in and record line-in (if you have a separate line-in and not only a mic in).


Gale

thanks - but I used to have this working without the cable trick so I know it can be done through configuration, so I don’t want to give in (yet).

That doesn’t sound like an Audacity problem. Have you checked Pavucontrol has not jumped to headphones or another playback device? I found it prone to that in Ubuntu 13.10.


Gale

Yes, I have checked.
While I am listening to Audacious playing a WMA file, the “Output Devices” tab of Pavucontrol shows port = Analogue Output/Amp, and the signal bar below shows activity.
If I then stop Audacious and play a midi file (using aplaymidi - p 17:0), I hear it fine, but Pavucontrol now shows no signal though the port stays at the same setting as before.

Similarly, the only change in the “Playback” tab when I switch sounds is the loss of the signal indication.

We don’t make PulseAudio. These people do: http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss . Let us know how you get on.

Check you are really pointing aplayer to the correct port.

Or you could try another MIDI player.


Gale

aplaymidi - p 17:0 sends the MIDI data to the MIDI synthesizer hardware of your SoundBlaster card which plays back directly from the hardware. That has nothing to do with PulseAudio. In effect, PulseAudio is bypassed, so pavucontrol will not “see” it and it cannot be recorded via PuseAudio’s “monitor” option.

If you use a software synth (such as Qsynth) then that will normally play via PulseAudio, making recording via PA’s “monitor” possible.

Thanks - I’ll take a look at that link.
I did try another player - Rosegarden - but same difference.
I will try Qsynth.

I installed Qsynth, and loaded it with the soundfont that comes with it.

Once again, when I played a midi (but this time specifying -p 128:0, so that Qsynth was used rather than direct to hardware), I could hear it fine but Audacity wouldnt record it and Pavucontrol didn’t display anything going on.

I had a look at the Qsynth setup to see if maybe I had to tell it to use Pulseaudio but there were so many options I couldnt tell what to do. I tried selecting Pulse as the audio driver but that made the playback stop.

I don’t know a lot about QSynth, but some pointers that may help:

(Update: Some information is updated in the next 2 posts, so read them too before attempting this)

Before you start, open a Terminal window and enter:

pacmd list-sinks

Look for the “sample spec:” line in the output. It will look something like:

sample spec: s16le 2ch 48000Hz

That tells you what sample rate PulseAudio is using. Use that sample rate for both QSynth and Audacity.

As a general tip, if you have any pavucontrol windows open, close them before making changes to your set-up. Open pavucontrol when you need it, then close the window.

Open QSynth. You may get an error message about being unable to start the audio engine - that’s OK, we haven’t set it up yet.
Click the “Setup” button.
On the “Audio” tab, set the “Audio Driver” to “pulseaudio” and the “sample format”, “number of channels” and “sample rate” to match PulseAudio (as previously shown in the Terminal). Everything else can probably be left at default for now (search on line for more details if required).
Click the “OK” button.
You may be prompted to restart the audio engine, if not, you can press the “Restart” button anyway and you will be asked to confirm.
That should be it for QSynth. Check if it is working.
When QSynth receives MIDI data you should see a green “light” in the lower left corner of the interface - that is how you can see if it is receiving MIDI.

Open Audacity. If it’s already open, exit and re-launch Audacity.
In the device toolbar, set the recording input to “default” or “pulse” (“pulse” is usually the “default”).
Set the “Project Rate” (lower left corner) to match the PulseAudio sample rate. You can set this as the default by going to “Edit > Preferences > Quality”)
Click on the recording meter to start monitoring. (there is also a drop-down menu, indicated by a small black triangle near the microphone icon).

Open PulseAudio Volume Control.
You should see “Fluid Synth” listed in the playback tab.
You should see Audacity listed in the recording tab.

If Audacity is not listed in the recording tab, click the record button in Audacity and it should then appear (it’s not always easy to see if the meters in Audacity are active or not).

Set the recording source for Audacity (in pavucontrol) to the Monitor option for your sound card. Note that if you have more than one sound card, there will be more than one “Monitor” - you need to select the one that “Fluid” is playing through.

Audacity should now be set to record “Fluid Synth” (QSynth is a GUI front end for Fluid Synth).

If all is well, close pavucontrol, and start recording.

For better performance, Jack Audio system should be used, but that’s another layer of setting up, so if PulseAudio works OK use that. If you have performance problems, you may need to investigate setting up your computer to use Jack Audio System (also known as “jackd”).
Why is this so difficult? Because computers these days are set up for general computing tasks, like running office programs, Youtube, web browsing and facebook. You are trying to turn it into a music studio.
Why was it so much easier on my old Windows 98 machine? Good question. That was in the days when on-line video was the size of a postage stamp - no full-screen YouTube back then - priorities have changed.

The bit about sample rates may not be quite right.
You may need to set Audacity and QSynth to both use 44100, regardless of the rate that PulseAudio is running at. Try 44100 first.

Ideally, PulseAudio should be running at the same rate (44100) but it should still be OK if it is running at 48000 Hz.

Thanks for all the help.

As a general tip, if you have any pavucontrol windows open, close them before making changes to your set-up. Open pavucontrol when you need it, then close the window.

I think that helps - I’d been getting crashes before I did this.

pacmd list-sinks

gave me

sample spec: s16le 2ch 48000Hz

.

Qsynth setup - the only thing I changed was the number of channels (was 1 - changed to 2). I left the rate at 44100.

Audacity - rate was already 44100.

Pavuctl - I could see “Fluid Synth” listed in the playback tab and Audacity listed in the recording tab. The recording source was already set to Monitor.

I did

aplaymidi  -p 128:0 song.mid

and when I hit the Audacity record button two things happened

  1. the sound stopped !
  2. I could see a waveform in the Audacity track indicating recording was happening :smiley:

I stopped the recording, exited Qsynth and went into Alsamixer and muted S/PDIF Optical Raw (a ‘feature’ of the soundcard - certain programs unmute this which disables sound) to get sound back. When I played back the Audacity track it was badly distorted. Might this be a sample rate issue ? I’ll try again with 48000.

Success at last (almost) :smiley: !

Changing everything to 48000Hz did the trick.

Playing a midi via aplaymidi into Qsynth and recording through Audacity now works.

What started this though, was my need to record midi played through the Wine/Firefox/Scorch player (source from sheetmusicdirect.com). By reconfiguring the Scorch player to use the Qsynth midi port I can now play that (no distortion) and record it as well BUT there is some distortion when I playback the Audacity recording (not a lot, but enough). Is this because I haven’t bothered with Jack ?

It may just be that the volume level on QSynth is turned up too high.

I turned the gain right down on Qsynth but it made no difference.
Furthermore, the distortion only occurs while Audacity is recording. If I stop the recording, the playback is clear.