Playback through Mic Channel

Mo Mahler's icon

Hello,
I am new to Max but was hoping to playback a prerecorded audio file through the mic channel. So a user could potentially talk over a mic but also send an mp3 or wav file as well. Essentially, I need to be able to toggle the microphone to be both and input and output device.

Peter Ostry's icon

Do you expect your microphone to play music?
This does not work.

Mo Mahler's icon

No, that channel would be used as an input channel to feed a remote speaker.

Peter Ostry's icon

Ok. So you have a mic and a speaker at the singers place. You won't find an audio interface that uses an input channel as output, so you got to use an input and an output on the interface/computer. Means, a plug for each. On the singer's side you also need two plugs.

The transfer could theoretically work with a standard mic cable if the mic- and the speaker-line are unbalanced and share the same ground. But you should definitely not try it this way for several reasons. You need two cables.

If you don't want two independent cables, you may use a "twin audio cable", which combines two symmetrical lines. For example the Cordial CMK 422 Twin. These cables aren't expensive and pretty good. Solder the plugs you need to both ends.

With this setup, there is no problem in Max or other software because you simply have one input and one output.

Mo Mahler's icon

I am looking for a pure software solution. It would be fine to toggle the mic to be disabled while that channel is broadcasting the pre-recorded audio. Imagine, for example, a Skype session, and playing back a file directly to the mic channel.

Peter Ostry's icon

Sorry, I still don't get the idea "playing a file to the mic channel". Sounds like mounting the speaker in front of the mic, which would be an odd setup.

Disabling the mic while the output plays can be done in Max. Manually, MIDI controlled, automatic switch or using a ducker or whatever.

Mo Mahler's icon

Similar to this product.
https://store.steampowered.com/app/629520/Soundpad/
"Play sounds in voice chats in high digital quality."

Peter Ostry's icon

Now it is clear, thanks. There is nothing like "using mic input as output". Soundpad is a software audio mixer with some features. Basically you can make such a thing yourself, even without much knowledge of Max. The complicated parts are the features of Soundpad. For example, adapting file playback level to mic level is not an easy task and requires some skills in digital audio processing.

Think about three stages: Source —> Mix —> Output

Source:
Audio sources are your microphone input and your audio files. The mic comes in from your interface via the [adc~] object. The signals from audio files may come from one or more [sfplay~] objects which you have to control in some way.

Mix:
You need a mixing stage to combine the sources in the way you want them. If there are more than two input/output channels, I can recommend the [matrix~] object as the 'core' mixer. You can set routing and gain within this object in various ways.
Compared to mixing itself, the 'normalization' feature like in Soundpad is complicated. You have to measure the mic input level (rms, average, ramp smoothing, snapshot etc.) and adapt the audiofile's playback levels accordingly. You may have to control the mic level also. Measuring is done before [matrix~], the levels are set before or within [matrix~], plus a main level between [matrix~] and the output.
If you do not need the auto-level-feature, you just make a switching or blending patch where you control the levels. For simple soft-switching with adjustable speed, the ramp feature of [matrix~] may be all you need.

Output:
Finally you have a [dac~] object as your output. It sends your mixer's output channels to your audio interface and/or to software.

I hope this overview helps. As I said, automatic level control is not an easy task. You may consider to prepare your audiofiles instead, by bringing them to equal levels. This would make the whole mixing stage much simpler, because you would have only two audio sources, "the mic" and "the file".