You are here

Midi Keyboard Recording/Playback

Another newbie here. New to Qtractor and digital music production in general.

My goal is to record my Yamaha P-85 keyboard to Track #1 then record to Track #2 while listening to Track #1, in effect simulating a duet. So far I haven't been able to do this. Is it possible?

I'm running Qtractor (0.9.34). MIDI interface is M-Audio Midisport 2x2. OS is Fedora 38 (recent version, uses Pipewire).

I'm able to play notes on the keyboard and hear the notes on the keyboard's internal speakers using midi (no synthesizer). There's a huge delay (seconds) between striking a key and hearing the output. I assume this is what's called latency. It's way to big for practical use. Would a "low latency" OS bring it down to a usable level?

When playing a song I've recorded the output is messed up. The notes are right but the timing fluctuates. That is, it speeds up and slows down slightly. Chords sound like fast arpeggios, that is, the notes are not played together. Does this mean I'll have to edit each note to get the timing right? This is of course impractical.

Obviously, I don't know much about how midi recording works. How are instruments synchronized so they play together like a band? Hopefully you don't have to edit each note of every instrument. That would be massively impractical.

Thanks for your help!

Forums: 
rncbc's picture

hi, you're welcome

yes it's perfectly possible to do what you ask, recording and playback several tracks at once.

but first you'll have to sort out that horrible MIDI latency/jitter problem, which is huge and impossible to work with anyway...

maybe the problem is in the midi-usb interface and/or pipewire(-jack) I presume... you'll need to describe in way more detail how exactly are you wiring the MIDI-keyboard to the computer and ultimately to qtractor...

is that the original midisport 2x2 of the beginning of the century (old midiman, lime green case) or is it a recent one (anniversary, black case)? believe the former needs a firmware update to run on Linux while the later is fully usb1.1 class-compliant so no need for special driver software... but really don't know whether the problem is in either end or both...

you most certainly need to tune up your kernel for low-latency (eg. boot option preempt=full), review your pipewire(-jack) configuration and probably force a qtractor's midi queue timer to the highest resolution (HR) if not the system default...

seeya

Thanks for your response.

Are you sure my goal is possible in the real world? Does it require a super computer? I tried to get this to work several years ago on a less capable computer but gave up because of the latency problem. I'm trying again now to see if anything changed over the years. So far I'm not seeing much improvement in latency.

Today I installed "Fedora Jam". It's a version of Fedora designed for audio production so I assume it has the proper kernel optimizations. It comes with Qtractor pre-installed (and several other audio production programs). Unfortunately, the latency is not much better than Qtractor on plain vanilla Fedora 38. I'm running Fedora Jam from a live CD without installing it on my hard drive. I wonder if that causes latency. I hate to wipe out my hard drive to install Fedora Jam only to find out it makes no difference. However, I'd surely go through with it if I knew it would solve the problem.

My hardware setup couldn't be simpler. My M-Audio midiman device (black Anniversary model) is connected to the keyboard's DIN jacks on one side and to the computer's USB jack on the other.

Any other thoughts/comments are greatly appreciated.

Success!!

Installing and running "Fedora Jam" from the hard drive eliminated audible latency. The Live CD is not a reliable way to evaluate applications included with Fedora Jam. It could lead to mistakenly rejecting the system/applications.

I can finally move on to other things. However, I'm afraid I might wake up tomorrow and realize I was dreaming.

The morning after installing Fedora Jam I discovered it didn't improve latency at all. I thought it was working perfectly when I installed it late the night before but I had a parameter set wrong and was actually listening to keyboard output directly, not through the computer. In fact latency was variable. It could take up to 10 seconds from when a key was pressed until the note was heard.

After an untold number of hours reading about MIDI, real time OS, looking at Youtube, and reading Qtractor documentation I finally in desperation tried another MIDI interface. I purchased a cheap interface for about $3 on TEMU. Users said it worked fine, and by golly it seems to have eliminated latency completely, at least so far. I assumed my M-Audio Anniversary MIDI interface was reliable, but obviously not.

But there's bad news. My damper pedal doesn't work correctly. It sometimes plays a note, specifically the E above middle C. And it does other weird things occasionally, like refuse to stop damping when the pedal is released. Somehow pedal data is getting modified either in the MIDI interface or the software. I know this is true because I used a MIDI cable to connect the keyboard OUTPUT directly to the keyboard INPUT. The damper pedal worked correctly.

So that's where I am now. Latency appears to have been eliminated. But the system is still not usable because the damper pamper pedal doesn't work correctly. Any suggestions are greatly appreciated.

Many thanks to all of you who have responded already.

rncbc's picture

so, after all it seems it was your midiman the culprit? who would tell? Before you send it to the trash bin, please try with another computer at the least: it might be the USB host controller at the stake... now, are you possibly using a usb-hub of some sort? it might be not powering the midiman properly or somehow the new and cheap interface needs lower power requirements, idk... have you tried to plug it in in some other usb-port?

on the damp pedal trouble: how is that even supposed to work? i guess you plug it in directly to the midi keyboard and that's it! the corresponding midi events should appear through midi to the computer and possibly recorded into the daw (qtractor or else); it seems (very) strange that you need to feedback the pedal output (which is probably just an electric switch that only the keyboard understands as such) onto the keyboard again--question is, is it really midi? if not, probably that's the whole trouble and misunderstanding you're having ever since the start? idk...

please

You guessed right. The damper pedal is an on/off switch that plugs into the back of the piano.

I don't think there's any doubt that the Yamaha P85 is a midi keyboard, probably one of the most common piano keyboards around. Google it. You'll find many references including the owners manual that includes midi technical info in the appendix.

I don't understand why you feel it strange that damper pedal events need to "feedback" into the keyboard. The damper is a crucial part of a piano performance. However now that you mention it, it does seem that the pedal should be on its own channel. I mean, if I record the left hand on one track and the right hand on another track should the damper pedal be recorded on both tracks? That wouldn't make sense. It raises a question I haven't even considered. That is, Is it possible for one instrument to play the output of multiple tracks at the same time? Wow, this blows my mind. Maybe it's not possible to do what I'm trying to do.

My understanding is that in a midi recording setup each instrument has it's own track. But what happens when you have two tracks that use the same instrument. Should that be an error? Qtractor doesn't prevent it. I'm very interested to hear what you have to say about that.

Finally, regarding channel numbers. When creating a midi track in Qtractor what does the channel setting do? Qtractor recognizes my keyboard no matter what input channel setting I specify. I don't even know what channel my keyboard is using. But it doesn't seem to matter. Qtractor recognizes it anyway. Also, what's the "Omni" checkbox for? I assumed that means the track should accept input from all channels. It doesn't seem to make any difference whether that box is checked or not.

Thanks again for your time and consideration.

rncbc's picture

re. Is it possible for one instrument to play the output of multiple tracks at the same time?

yes

re. what does the channel setting do?

it assigns a channel number to a track; when recording, only the incoming events on that exact channel will get recorded to that track; when in Omni mode, it means that any channel number will do; on playback, events are always played on the exact track's channel number, no matter what their original recorded channel was.

now, at this time you'll need to know that there's this Track > Auto Monitor setting that makes all incoming events automagically translated to the channel of the current highlighted track; this is just a convenience set for most midi keyboards that play on one single channel and players that wish to record or play live on one single track at a time; maybe it's not your case?

if your keyboard is configured to send events over several midi channels at once, then this Auto Monitor setting is simply foul play, as all input events will get aliased to the same channel number, the one of the current track, and that is probably the root of some if not all of your troubles---turn it off then.

one other thing, do you have ANY of "monitor" buttons turned on? please don't, ever or a least not yet; turn them all off, please.
having any of these on will make all incoming events pass-through to output and quite possibly get feedback to the midi-keyboard midi-in, if connected that way, which I think you do since you said you "don't understand why [I] feel it strange that damper pedal events need to "feedback" into the keyboard"; could it be the root of all bad things that happen in your case? idk. you tell me :)

on a similar don't do it vein, do you have your computer's midi-in (incoming from the keyboard's own midi-out) connected directly to the device's midi-out (outgoing to the keyboard's midi-in)? can you show us the whole picture of your audio/midi connections? if you're using qjackctl, a screenshot of the Graph will do.

one last thing, can you monitor all the midi input of your usb-midi interface device (midiman or else) ? use aseqdump to the rescue, please.

hth.
seeya

Thanks rncbc,

I will attempt to provide the information you requested. It will be interesting to see the output of aseqdmp. I've never used it before so I'll have investigate how to use it. In the mean time I've found evidence that others have encountered the same damper pedal problem according to the following link. No solution was described unfortunately.

https://gearspace.com/board/audio-student-engineering-production-questio...

I have found that the pedal works correctly in one situation. Specifically, if I press and hold the pedal down a few seconds before releasing it works. A short press and release causes the E3 note to play, as the users in the above link describe. After E note playing begins subsequent pedal presses repeat the E note when the pedal is pressed down. It takes a pause between presses of about 15-20 seconds or so to restore "normal" operation.

rncbc's picture

so it's a general issue with the hardware after all, not one to blame on qtractor (nor to linux), i guess...

you still didn't tell a word about that nasty potential positive-feedback-loop scenario, wrt. monitor/pass-thru... do believe you're still in trouble if that situation is still on...

cheers

Thanks again for your time and consideration but it does seem that I'm dealing with a hardware issue now. I joined the forum that I mentioned earlier to ask if the issue had been resolved. Even though the conversation was 10 years old one of the participants responded immediately and said no resolution was found. He got rid of his P85. He suggested I try yet another midi interface. He indicated that he's had strange problems with several of them before.

I also feel the interface could yet be the problem. There's evidence that the keyboard is not the problem, in my opinion. I mentioned earlier that I connected the keyboard's midi OUTPUT port directly to its midi INPUT port using a midi hardware patch cable. The P85 owners manual describes how to disable the keyboard internally so that only the midi OUTPUT is transmitted when a key is pressed. The internal connection between the keyboard and synthesizer is disabled. With this setup the keyboard is in effect connected to the internal synthesizer remotely. I don't recall having any problem with the damper pedal with this setup. Right now I'm away from home and don't have the patch cable so I can't verify this setup again until next week. I do have the keyboard and computer with me however.

In summary, my next step is to try yet another interface to see if the problem persists.

I did try the aseqdump utility. It confirms that when the damper pedal is pressed and released slowly everything works properly. But when the pedal is pressed down immediately (within seconds) after a prior release a midi NOTE ON 64 127 message is generated and the E note sounds at maximum volume. Of course this message is coming from aseqdump output which is after the midi signals have passed through the midi interface and the computer's usb device driver. I don't know for sure what's coming out of the keyboard's OUTPUT port directly. I assume the patch cable setup would confirm that in bypassing the computer/interface.

Sorry I ramble on.

I'll keep working on this for a while and post any progress.

SOLUTION
I understand that you want to take advantage of the feel and counterweight of a digital piano.

Nowadays, a keyboard with USB-MIDI is the standard and will give you fewer problems.

You can have several midi keyboards connected at the same time, either in series or in parallel.

To the subject:
Use a cheap USB keyboard (MIDI controller) to connect the pedal, and leave the piano for the musical performance.

If it is a hardware problem with the digital piano, this should work correctly, with the added advantage that you now also have a small midi controller with which to automate other issues.

HARDWARE IN LINUX
Before buying any Linux hardware you must check that it is compatible.
For me, the most effective thing is to consult it on Amazon, Thomann or a search engine: device "linux".

They say that Linux users are only 2%, but when you go to device comments, you see that there is a much higher percentage of users who ask or point out that this or that device is actually compatible.

I don't know why this insistence on falsifying the official percentages. But if I look at comments in online stores, and even in my immediate environment, my calculations say that we are not 2% but 20%.

Anyway, this last point goes beyond the topic discussed, but I think it is relevant to point it out.

Thanks for your comments and recommendation.

I too believe Linux is under reported as a percentage of the computer market. But Linux is it's own enemy in some ways. There are too many varieties and ways of doing common things. Take software installation for example. Why can't developers agree on one method? Mac and Windows users can go to any web site and install software directly. Linux users have to go to a repository for their distribution, they're almost guaranteed to never find the latest version of anything.

But back to the subject. I may go to my local music store and buy a Linux compatible midi interface, or maybe even one made by Yamaha, with the understanding that I can return it if it doesn't solve my problems.

One more response regarding your comment. You suggested creating a separate channel on a separate midi controller to isolate the damper pedal. That might work conceptually but I haven't been able to get channels to work in Qtractor. My controllers all seem to be recognized no matter what channel they're on. In addition to my Yamaha piano keyboard I also have a Yamaha organ. It has two keyboards ("manuals") and a foot pedal keyboard. They're on channels 1,2,3 according to the owners manual, but Qtractor combines all three no matter what channel I specify on a track INPUT setup screen. It's like the "Omni" box is checked, but it isn't.

But channels are a subject for another day. I need to get my damper pedal problem fixed first.

In any case, for what I was saying about the pedal it is indifferent. In fact, it is important that the pedal and key signals go to the same channel.

I forgot to mention that I have looked for every "Monitor" button I can find in Qtractor. None of them seem to be active. The indicator "LEDs" are all off.

Egg on my face but joy at last! I didn't pay attention carefully enough when you emphatically said what to do regarding Monitor settings. I looked at all the input/output Monitor buttons for each track. They were all off. But I overlooked your specific instruction to uncheck the "Track > Auto Monitor" box. I'm hesitant to say it but that seems to have fixed the damper pedal problem! I'm afraid I'll try again tomorrow and it won't work but for the moment everything seems to work correctly regarding both latency and damper pedal operation. I would never have been able to figure this out on my own because I can't relate to what the Monitor function is for, how it works, or why it's turned on by default. I'll just have to remember to turn it off.

I assumed the Monitor feature allowed sound to be heard through the computer's audio system while midi data is simultaneously sent to a synthesizer. But I don't see how that would have any impact on my problem. Anyway, as you said, it automagically works somehow.

There's so much I don't understand about midi and Qtractor but I'm optimistic that I'm over this hill.

Thanks for hanging in there with me!

c3po, I recommend trying out Ubuntu Studio. I came from Pop!_OS where it had recently moved to Pipewire. I had endless issues with stability and decided to try out Ubuntu Studio (still based on JACK) - everything works beautifully out of the box because it is configured for audio production (as well as a few other multimedia purposes). You may want to give it a shot.

Thanks for the heads up, hiji. If I had read your response a little earlier I might have given Ubuntu Studio a try but I happened to be trying Fedora Jam instead. The bottom line appears to be that a low latency version of Linux is really a prerequisite to successful operation of audio production applications. That can't be over emphasized in my humble and naive opinion. Quite likely everybody knew that but me.

Fedora Jam is based on Jack also. The regular version of Fedora uses pipewire.

For a modern operating system, Linux sure requires too much hand-holding just to get working.

Does anyone else really think that audio should be a lot simpler and more direct to access? Why do we have so many issues with inputs and outputs being named, not only from the wrong context (inputs as 'readable clients'? wtaf?) but with actually useless names or missing hardware out altogether?

Something tells me, that after 20 years, these things SHOULD be in a much better state than they currently are.

Words fail to express how embarrassing it is that Linux STILL has no consistent audio architecture which isn't broken or needlessly limited in some way.

There's a severe lack of consistency in rules and methodologies. Its' not like we just invented computers and don't know how they work. How is recording audio in a modern operating system so badly broken?

I swear, we've got something seriously wrong. I can't help thinking all this is just unfocussed over-engineering ad nauseam.

Also a red flag... ALSA, PulseAudio and now Pipewire - Reinventing ill-conceived architectures is symptomatic of modern software. We need to stop producing the same, ill-conceived square wheels with objectively bad, over-engineered workarounds.

I agree, jackuser. It does seem difficult to understand and get things working in Linux audio. But I've used Linux for years and I'm more comfortable with it than Windows. Because of the difficulty I have ordered a USB adapter for my iPad Pro. I'm going to give GarageBand a try. Things in the Apple world seem to be made for dummies, they seem work intuitively most of time.

I think a big part of my problems is that I've never worked with audio/midi recording at all. So I don't understand the meaning of the many specialized terms and concepts used to explain how a DAW works. I feel sure a recording engineer would have no problem understanding how programs like Qtractor are supposed to behave and what the items on the various screens mean. But it's a mystery to me. I've never even seen a patch panel for example. Furthermore I don't know how to find out what things mean without asking a million questions on a forum like this one. That can take forever.

Thanks for your response.

After days of trial and error my latency issues and pedal problem were found to be caused by my MIDI interface.

My M-Audio Anniversary interface works properly under certain conditions. This led me to believe that other things I tried eliminated my latency problems but it was only temporary. After restarting my computer latency returned.

I finally found that by connecting the cables and powering up my M-Audio in a certain sequence it works properly. The sequence has to be repeated every time the M-Audio is powered down.

For those that may be interested, and for my own future reference, here is the magic startup sequence for the M-Audio. First power down the M-Audio by unplugging its USB cable. Confirm that the mode button is in the "In" (USB/merge) position. Connect the keyboard's midi output cable to one of the M-Audio's input jacks, either "In A" or "In B". Apply power to the M-Audio by plugging its USB cable into the computer. Latency will be horrendous. Unplug the keyboard output cable from the M-Audio and plug it into the other M-Audio input jack. The M-Audio will then work properly, latency will be eliminated (and the damper will work). For example, if the keyboard output cable is connected into "In A" when power is applied to the M-Audio then it must be moved to "InB" after power is applied. That's it! So far it seems to work every time.

I also tried two cheap interfaces that were identical. They both failed in different ways, but they both eliminated latency. One didn't send NOTE OFF events, so every note played on the keyboard lasted forever. The other sent random E3 notes at velocity 127 when the damper pedal was pressed repeatedly. These interfaces are found all over the internet and range in price from $3 to $54. They look identical but have different names.

Add new comment