Sound-command produces click-noise in a loop after each tone
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I am trying to make my impedance curve audible. My procedure (in Matlab):
- normalize data (Z/mean(Z))
- normalized data * sound frequence (440 Hz)
- determine the time per tone with e.g. 0.1 s (here I need a "time-array", because later I want to add the capacitance as the time => every tone another time (same for the duration). Now I want to add all these single tones to one "song" (background: I am working with impedance curves and have to explain my work to non-professionals - perhaps it will be easier with audible support =) )
Now my problem: after every single tone there is a "click"-noise, like turning old speakers on and off. I also tried to stick the sound vectors first together and play then the "sound-total" at one piece - does not work, too =/
Does anybody have an idea, why this click-noise is present? I would really appreciate that =) Furthermore, the sound is not around 440 Hz. Does anybody have a good working code for a sinusoidal sound?
I have spent so much time for this and I do not figure it out.
Thanks in advance. Regards,
elchico
My Code:
%%config settings
filename = 'Z_data.dat';
delimiter = '\t';
sound_freq = 440; % in Hz, middle value to fluctuate around
fs = 20500; % Sampling frequency
dt = 1/fs; % time resolution
num_points = 10; % How many points of raw data to convert into sound?
for jj = 1:num_points
duration(jj,1) = 0.1; % duration per note in sec
amplitude_array(jj,1) = 1; % a.u., middle value to fluctuate around (=> volume)
end
%%calculate values (Z_norm) and refer to sound
M_raw = dlmread(filename,delimiter);
Z_values = M_raw(1:num_points,1);
Z_norm= Z_values /mean(Z_values );
sounds_freq_array = Z_norm*sound_freq,0;
%%play sound
for ii= 1:num_points
t = 0:dt:(duration(ii,1));
signal = amplitude_array(ii,1)*sin(2*pi*sounds_freq_array(ii,1)*t);
sound(signal, (fs));
pause (duration(ii,1));
end
And here are some example-data:
8406
8200
8000
8500
8365
8400
7999
8555
8336
8456
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!