Sound synthesis, problem when I add sounds, there is a snapping sound
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm making a code which convert image to sound. I process the image to get different objexts and the I associate each object to a frequency according to its position in the image. Then, for each line of pixel's column, I create a sound and i add every sound of a column to make a chord that I call "accord" and then I concatenate every "accord" to make a music. My problem is that between to "accord" there is a sound which makes the music not smooth. I don't know how to do, not to have this sound, could you help me ?
Here is my program :
for i = 1 : 500 %number of column
accord = 0;
for e = 1 : nRowResized
if imageObjet(e,i) > 0
AmpSon = log(1000000+stats(imageObjet(e,i)).Area);
Duree = double(int16(noteObjet(imageObjet(e,i))))/(noteObjet(imageObjet(e,i)));
son = note(noteObjet(imageObjet(e,i)),Duree,AmpSon,6000); %freq, durée, amplitude, fe
else
son = note(0,1,5,6000); %freq, durée, amplitude, fe
end
if length(accord)>length(son)
son(numel(accord)) = 0;
end
if length(accord)<length(son)
accord(numel(son)) = 0;
end
accord = accord + son; % add every sound of a culumn to make a chord
end
musique = [musique accord]; %concatenate chords to make the music
end
1 个评论
Mathieu NOE
2022-5-11
hello
maybe you should make sue that the "connection" between the last and next section (accord) is smoothed . there may be discontinuites. So apply a window that makes sure the data converge towards zero or make a kind of local smoothing of end / start sections
回答(1 个)
Milan Bansal
2023-12-29
Hi Louis Vitaloni,
It is my understanding that you are trying to concatenate chords ("accords") to create some music but there is some unwanted noise between the two chords ("accord").
The unwanted sound between the chords could be due to abrupt changes in the waveform at the point where one chord ends and the next begins. This can create a popping or clicking noise.
A short crossfade between the end of one chord and the beginning of the next chord can be implemeted to smoothen the transition. Please apply fade out at the end of the already concatenated chord ("musique") and fade in at the beginning of the incoming chord before concatenating them. Please refer to the pseudo in code snippet below: -
fe = 5000 % sampling frequency. Please change this value as per requirement
fadeDuration = 0.05 % Please change this value as per requirement
fadeOut = linspace(1, 0, fe * fadeDuration);
fadeIn = linspace(0, 1, fe * fadeDuration);
% Multiply fadeOut and fadeIn to the end of "musique" and fadeIn to the "accord"
musique(end-length(fadeOut)+1:end) = musique(end-length(fadeOut)+1:end) .* fadeOut;
accord(1:length(fadeIn)) = accord(1:length(fadeIn)) .* fadeIn;
musique = [musique accord]; % Concatenate the chords
Hope it helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!