简体   繁体   English

如何将两个声道的音频转换为一个声道的音频

[英]How to convert two channel audio into one channel audio

I am playing around with some audio processing in python. 我在玩一些python音频处理。 Right now I have the audio as a 2x(Large Number) numpy array. 现在,我将音频作为2x(Large Number)numpy数组。 I want to combine the channels since I only want to try some simple stuff. 我只想尝试一些简单的东西,所以想合并渠道。 I am just unsure how I should do this mathematically. 我只是不确定如何数学上做到这一点。 At first I thought this is kind of like converting an RGB image to gray-scale where you would average each of the color channels to create a gray pixel. 起初,我认为这有点像将RGB图像转换为灰度图像,在该图像中,您将平均每个颜色通道以创建一个灰色像素。 Then I thought that maybe I should add them due to the superposition principal of waves (then again average is just adding and dividing by two.) Does anyone know the best way to do this? 然后我想也许是由于波的叠加原理而应该将它们相加(然后平均值又只是相加并除以2。)有人知道这样做的最好方法吗?

i handle this by using Matlab.python can do the same. 我通过使用Matlab.python处理此问题。 (left-channel+right-channel)/2.0 (左声道+右声道)/2.0

To convert any stereo audio to mono, what I have always seen is the following: 要将任何立体声音频转换为单声道,我一直看到以下内容:

For each pair of left and right samples: 对于每对左右样本:

  1. Add the values of the samples together in a way that will not overflow 以不会溢出的方式将样本的值相加
  2. Divide the resulting value by two 将结果值除以2
  3. Use this resulting value as the sample in the mono track - make sure to round it properly if you are converting it to an integer value from a floating point value 将此结果值用作单声道轨道中的样本-如果要将其从浮点值转换为整数值,请确保将其正确舍入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 仅在一个通道上生成音频 - Generate audio on just one channel pyaudio 如何使用 ffmpeg-python 从视频中获取第一个音频通道? - How to get the first audio channel from a video with ffmpeg-python? Pygame中如何调节特定声道的音量? - How do I adjust the volume of a specific audio channel in Pygame? 将 Python 中的两张灰度图像转换为一张 2 通道图像 - Convert two grayscale image to one 2 Channel Image in Python 如何使用PIL将1通道图像转换为3通道? - How to convert a 1 channel image into a 3 channel with PIL? 如何使用 opencv2 将 1 通道图像转换为 3 通道? - How to convert a 1 channel image into a 3 channel with opencv2? (Discord.py) 如何检查机器人是否已经在语音通道中播放音频? - (Discord.py) How to check whether bot is already playing audio in a voice channel? 使用 discord.py 在 vc discord 中播放音频 - InvalidArgument: 传递的通道必须是语音通道 - Play audio in vc discord using discord.py - InvalidArgument: Channel passed must be a voice channel 将 3 通道图像转换为 1 通道 python - Convert 3 channel image to 1 channel python 如何将1通道numpy矩阵转换为4通道单色图像 - How to convert 1-channel numpy matrix to 4-channel monochromatic image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM