WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Creation of Sound out of Data

 

elchico
Forum-Fortgeschrittener

Forum-Fortgeschrittener


Beiträge: 87
Anmeldedatum: 04.05.17
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 12.10.2017, 10:59     Titel: Creation of Sound out of Data
  Antworten mit Zitat      
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

    RealZ = M_RTC(:,3);
    ImagZ_cap = M_RTC(:,4);
    omega_Z = 2*pi*freq_RTC;
    ImagZ = 1./(omega_Z*ImagZ_cap);

    RealZ_norm = RealZ/mean(RealZ);
    RealZ_norm = ((RealZ_norm-1)*100)+1;
    ImagZ_norm = ImagZ./mean(ImagZ);
    ImagZ_norm = ((ImagZ_norm-1)*10)+1;

    sounds_freq_array = RealZ_norm*sound_freq;
    amplitude_array = ImagZ_norm*amplitude;
   
%% 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

    end
        pause (2);
        sound(signal_tot, fs);
       


clc;
Private Nachricht senden Benutzer-Profile anzeigen


elchico
Themenstarter

Forum-Fortgeschrittener

Forum-Fortgeschrittener


Beiträge: 87
Anmeldedatum: 04.05.17
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 12.10.2017, 13:05     Titel:
  Antworten mit Zitat      
I want to add an example matrix:

Code:
time                         impedance  real                             Cap
1,51500000000000   126260   126197   1,99468000000000e-07
3,03200000000000   126300   126237,500000000   2,00267000000000e-07
4,55000000000000   126300   126236,200000000   1,98212000000000e-07
6,06700000000000   126290   126226,400000000   1,98511000000000e-07
7,58300000000000   126250   126186,600000000   1,98945000000000e-07
9,10000000000000   126290   126226,700000000   1,99003000000000e-07
10,6170000000000   126280   126217,100000000   1,99679000000000e-07
12,1340000000000   126300   126236,500000000   1,98746000000000e-07
13,6530000000000   126280   126216,200000000   1,98330000000000e-07
15,1720000000000   126270   126206,500000000   1,98684000000000e-07



This is a real example with this crackle sound included.

Regards,
Private Nachricht senden Benutzer-Profile anzeigen
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

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
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2024 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

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.