create a dolby 5.1 wav file, put a sound file on the center channel in matlab

main.m
% Create a Dolby 5.1 audio file with sound on the center channel

% Load your audio file
[inputAudio, Fs] = audioread('input_sound.wav');

% Check if audio is stereo
if size(inputAudio, 2) ~= 2
    error('Input audio should be stereo!');
end

% Initialize 5.1 audio channels
numChannels = 6;
audioChannels = zeros(length(inputAudio), numChannels);

% Assign the stereo sound to the center channel (channel 3)
audioChannels(:, 3) = (inputAudio(:, 1) + inputAudio(:, 2)) / 2;

% Write the multi-channel audio to a wav file
audiowrite('output_dolby_5.1.wav', audioChannels, Fs, 'BitsPerSample', 24);
597 chars
20 lines

This code will create a Dolby 5.1 audio file with the sound from the input sound file placed on the center channel.

related categories

gistlibby LogSnag