Audio problems on nightly upgrade

Hi Chris,

Another issue has arisen. On upgrading from a 2021 (210118) nightly to a 2023 nightly (231018), we are finding that the sounds MWorks plays sound different.

I’m attaching a small WAV file that we play in MWorks.

I’m also attaching two audio clips that Nina recorded. The first - 13_47_41 - is what MWorks sounds like after the upgrade, and the second, 13_53_17, is what MWorks sounds like before the upgrade.
Note that these are different sequences of tones. Nina says that if this is too confusing she can record two sequences that are more alike in the sound files played and their order.

The machine is running MacOS 10.14. I can’t really think of something that might be going wrong. No other changes besides the MWorks upgrade (and a new Labjack plugin).

Any thoughts?
Best,
Mark

Hi Mark & Nina,

MWorks’ audio stimuli got a major revamp and upgrade between the two nightly builds you’re comparing. (For details, see the MWorks 0.12 release notes.) I wouldn’t expect audio files to sound different, though.

To test, I played 200msSq.wav three different ways:

  1. in QuickTime Player
  2. in MWorks 0.11 (pre-audio revamp)
  3. in the currently MWorks nightly (post-audio revamp)

It sounded the same to me all three ways. The only (very slight) difference I noticed was that, with MWorks 0.11, the beginning sounds a bit smoother. I think this reflects the fact that, prior to the audio revamp, MWorks could potentially drop 10-20ms of samples from the beginning of the audio file, whereas post-revamp it does not. That’s going to be more noticeable with a very short sound file like 200msSq.wav.

All that said, maybe something’s happening on your system that isn’t happening on my mine. I can’t really parse the two example recordings Nina made. Maybe you can record just 200msSq.wav playing once on each MWorks version, and send me those recordings? I’ve attached the very simple MWorks experiment I used to do my tests.

Thanks,
Chris
play_sound.mwel (83 Bytes)

Hi Chris,

I wasn’t able to get the mwel you sent over working but I used an experiment we have to play a 200ms square wav file. Both files are identical. The recordings sound pretty accurate to me, though there is some background white noise.

Both versions are attached.

Thank you,

Nina

I realize I should just send the file I played.

Hi Nina,

I wasn’t able to get the mwel you sent over working

I didn’t include the audio file – figured you could add that yourself.

I’ve repackaged the test to include the file. Maybe you can try running it on your old vs. new setups, just to confirm you get consistent results?

I used an experiment we have to play a 200ms square wav file. Both files are identical. The recordings sound pretty accurate to me, though there is some background white noise.

Thanks for that. I can hear the difference very clearly. (FYI, when I run my test with 200msSq.wav, it consistently sounds like your “2021” recording, regardless of what method I use to play the file.)

A few questions:

  1. Were your “2021” and “2023” recordings made on the same Mac or two different Mac’s?
  2. On the Mac where you made the “2023” recording, what happens when you play the audio file in QuickTime Player (found in the system “Applications” folder)? Does it sound like the “2023” recording, the “2021” recording, or something else?

Thanks,
Chris
play_sound.zip (25.3 KB)

Hi Chris,

To keep you in the loop, we did some testing yesterday. We were using 0.11 MWorks on a setup, everything sounded normal, and then we pushed the new code, and the sounds distorted on the same rig. We tried this on a second setup and the same thing happened.

At this point, we now know that all sounds (internal and external to MWorks) are normal coming out of the computer, but distorted coming out of our speaker ONLY after we’ve loaded our mwel file. This makes it seem like maybe it has something to do with changes we’ve made to our mwel or our LabJack Plugin, which was updated at the same time to be compatible with the mwel. I’m not sure if this is something you and I can troubleshoot or we should wait for Mark, who will be in and out this week.

Let me know what you think and thanks for the help thus far,

Nina

To clarify: Our LabJack connects an external speaker to the computer, and all sounds (mwel triggered sounds, sounds for other apps, etc.) are distorted coming through this speaker after (not before) we load our mwel.

Sounds are always normal coming out of the internal computer speakers, whether the mwel is loaded or not.

Yep, thanks Nina. Let me chime in with a few more details.

The precise changes we made were: (1) upgrading from the 0.11 nightly to the newer nightly (2) some changes in our Labjack plugin (3) some MWEL changes to support the new nightly.

Based on what Chris said about redoing the audio system in MWorks across this nightly upgrade, I’m thinking that it has to do with those MWorks changes.
Chris, I think we sent the WAV files we are using - that sounded normal before the upgrade and odd after the upgrade.

What else do you need to test this?
Nina is ready to send more info on request - she’s interested in dealing with this to avoid changes to her animal training.

Mark

Hi Nina,

Thanks for the update and additional info.

Our LabJack connects an external speaker to the computer, and all sounds (mwel triggered sounds, sounds for other apps, etc.) are distorted coming through this speaker after (not before) we load our mwel.

I don’t understand how the LabJack connects an external speaker to the computer. Can you explain?

Also, can you point me to the MWEL file that you’re referring to? I can access your ExperimentXML repository, so I just need a path in that (unless you’re working on a private branch).

Thanks,
Chris

Thanks Chris.
One more commment in case it saves you time. The python client code we use sets the system volume to a fixed value at start of each trial. This is because we are using the Mac audio system to play sounds and want them at constant volume. I used AppleScript to do this when I first wrote this a long time ago. I don’t think this is doing anything besides volume setting, but maybe it is involved.
However Nina said the issue comes from loading the MWEL, not running the first trial, so if that’s true this isn’t likely the issue.

Also there are conda environments in the PythonBridgeCode directory that you can use to run the python client bridge code.

Nina, you’re saying that

  • before HADC19 MWEL load, Mac sounds appear normal, both from internal speakers and this external speaker.
  • after HADC19 MWEL load, Mac sounds become distorted when played through the external speaker but not the internal speaker.

Yes, exactly.

ExperimentXML branch and experiment:
2310/lasertriggeringmwel
HoldAndDetectConstant19.mwel

I just tried Mark’s suggestion

I believe that this is plugged directly into the external (2.5mm) jack on the iMac. (but Nina should verify; there are long cables but you can unplug and replug while playing to test.

I have unplugged and replugged the jack on the monitor we use that plays the sound. It still sounds distorted after replugging it in. Then I closed the experiment. It sounds distorted still. I paused and replayed the sound which is playing from Quicktime. Distorted. Quit the QuickTime app, reopened the QuickTime app. Sound is still distorted. Quit MWorks. Sound is normal.

In relation to Mark’s comment about the volume, I have tried manually adjusting the volume after loading the mwel. It still sounds odd just quieter/louder. I agree, the issue is related to loading the mwel not to the first trial.

cc, Mark

Hi Nina & Mark,

I believe that this is plugged directly into the external (2.5mm) jack on the iMac

What happens if you unplug the external speaker from the jack on the iMac, connect a pair of wired headphones to the same jack, and then perform your tests while listening on the headphones? Does the sound still become distorted when you load the experiment and revert to normal when you unload it?

Thanks,
Chris

The monitor, which emits a sound, is actually connected with an HDMI cable. I did try to use the computer’s audio jack and it seems unaffected. Sound is normal in all circumstances out of headphones.

Hi Nina,

We were using 0.11 MWorks on a setup, everything sounded normal, and then we pushed the new code, and the sounds distorted on the same rig. We tried this on a second setup and the same thing happened.

Just to be clear, are you saying that, without upgrading MWorks, just switching to your updated MWEL code resulted in distorted sound, on two different machines? Or did you also upgrade MWorks on both machines?

Sound is normal in all circumstances out of headphones.

Thanks for trying that.

If the sound is always normal out of both the internal speaker and external headphones, then I’m having a really hard time imagining how MWorks is triggering this issue. Clearly, MWorks is extracting the correct audio samples and delivering them to the system audio output. After that, everything is in the hands of the OS.

And yet, somehow loading your experiment is breaking the audio output on your display.

You say the display is connected via HDMI. So the audio is coming over HDMI, too? I don’t think any remotely recent iMac model has an HDMI port. Is the monitor connected via an adaptor directly to a Thunderbolt port on the iMac, or is it connected to an external hub with HDMI and other ports? If you’re using a hub, what else is connected to the hub? In particular, is the LabJack connected to a USB port on the hub? Just grasping at straws here.

Thanks,
Chris

Another idea: If you open the “Audio MIDI Setup” application (found in /Applications/Utilities) and select the entry for the monitor’s audio output, what do you see? In particular, are the format settings different than for the built-in speakers and the headphone output? For reference, here’s what I see when inspecting my iMac’s built-in speakers:


Thanks,
Chris