Verfasst am: 12.10.2017, 10:59
Titel: Creation of Sound out of Data
Hello,
I want to convert my signal (time course of real and imaginary part of impedance) into a sound signal (with real part as sound-frequency and imaginary part as sound-amplitude) and of course the time as sound-timeline.
I have accomplished everything of the task already, BUT: when I play the signal, after each sound note there is a crackle. It is not there, when I load "gong.mat" or something else in matlab, so there have to be some issues with my code, but I do not know where.
Does anybody know, why there is this crackle sound? The problem occurs (in my opinion) in the "create signal". Can I "smooth" the sound signals somehow? Is it a soundcard problem? The problem seems to be, that the membrane of the speakers play one sound and then "go back in the idle position" and then play the next sound and this "idle position" can be heard as a crackle sound. But I do not know, if this is the right explanation ...
Thanks and regards,
elchico
Code:
%% config settings
filename = 'impedance.dat';% incl. extension
delimiter = '\t'; % Or ',' or ';' or ...
freq_RTC = 4000; % in Hz
sound_freq = 440; % in Hz, middle value to fluctuate around
amplitude = 1; % a.u., middle value to fluctuate around (=> volume)
%duration = 1; % duration per note in sec
fs = 44100; % sampling rate
phi = 2*pi*0.5; % phase offset, e.g.: 2*pi*0.25 = 1/4 cycle
%% calculate Imag + Real and refer to sound
M_RTC = dlmread(filename,delimiter);
% impedance matrix: % time impedance real capacitance
%% config output settings
T = 1/fs; % sampling period
%% create the signal per pair of values
signal_tot = 1;
for ii= 1:10 %numel(sounds_freq_array) if ii == 1
duration = M_RTC(ii,1);
else
duration = M_RTC((ii+1),1) - M_RTC(ii,1);
end
duration = duration/3;
omega_sound = 2*pi*sounds_freq_array(ii,1);
t = 0:T:duration; % time vector
signal = cos(omega_sound*t + phi)*amplitude_array(ii,1); % sinusoidal partial if signal_tot(1,1) == 1
signal_tot = signal;
else
signal_tot = [signal_tot,signal];
end
time impedance real Cap
1,515000000000001262601261971,99468000000000e-07 3,03200000000000126300126237,5000000002,00267000000000e-07 4,55000000000000126300126236,2000000001,98212000000000e-07 6,06700000000000126290126226,4000000001,98511000000000e-07 7,58300000000000126250126186,6000000001,98945000000000e-07 9,10000000000000126290126226,7000000001,99003000000000e-07 10,6170000000000126280126217,1000000001,99679000000000e-07 12,1340000000000126300126236,5000000001,98746000000000e-07 13,6530000000000126280126216,2000000001,98330000000000e-07 15,1720000000000126270126206,5000000001,98684000000000e-07
This is a real example with this crackle sound included.
Regards,
Einstellungen und Berechtigungen
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.