Matlab Signal processing

Discussion in 'Programmer's Corner' started by BuriedMoon, Mar 29, 2010.

  1. BuriedMoon

    Thread Starter New Member

    Mar 2, 2010
    22
    0
    Hi,
    How do i find the start and the end of the envelope from an audio signal ?
     
  2. johndoe45

    Member

    Jan 30, 2010
    364
    1
    if variable is like t for time

    then type t(1) in command window

    and maybe t(end)

    might work

    or t(length(t))
     
  3. BuriedMoon

    Thread Starter New Member

    Mar 2, 2010
    22
    0
    Is it going to work?
    Cause basically i'm using hilbert transform to extract the envelope for the speech signal .
     
  4. johndoe45

    Member

    Jan 30, 2010
    364
    1
    i don't know. never tried it. but t(1) is initial time
    and t(length(t)) is final time

    variable could be x or anything so i don't know without seeing the function.

    i think its n(1)
    n(end) or n(length(n))

    just try it and see if it gives you anything.
    this is just how many points are taken. but to compute the time i wouldn't know

    just look at the side and it has has how long the arrays or vectors are
    will say like 1 x 100 which means one row with 100 columns. so 100 elements

    fh=[0:Lh-1]/Lh-0.5

    therefore x axis is from 0 to length(Hh)-1

    so type length(Hh)-1 and returns final value

    i don't know

    check this site out
    https://ccrma.stanford.edu/~jos/sasp/Comparison_use_hilbert_function.html
     
    Last edited: Mar 29, 2010
  5. BuriedMoon

    Thread Starter New Member

    Mar 2, 2010
    22
    0
    if gives undefined variables..:)
    Do you want me to post up my m-file for you to read up ?
     
  6. johndoe45

    Member

    Jan 30, 2010
    364
    1
    yes please. hurry. i'm tired
     
  7. BuriedMoon

    Thread Starter New Member

    Mar 2, 2010
    22
    0
    function [data,fs,smoothData] = Uload()

    [filename, pathname] = uigetfile('*.wav','Select Data File');



    if filename ~= 0

    cd(pathname);

    % Get data and sampling rate

    [data,fs] = wavread([pathname filename]);

    % length(data)
    % fs
    data = data/max(data:)));
    hwin1 = subplot(221);
    xlabel('Samples')
    ylabel('Signal (Volts)')
    ldata = length(data)
    tdata = 1:ldata;
    cdata = hilbert(data);
    [b,a] = butter(5,20/(fs/2),'low');
    smoothData = filtfilt(b,a,abs(hilbert(data)));
    plot(tdata,2*smoothData,tdata,abs(cdata))
    hwin2 = subplot(222);


    % [b,a] = butter(5,20/(fs/2),'low');
    % smoothData = filtfilt(b,a,abs(hilbert(data)));
    % plot(smoothData)
    p = fft(data);
    ls = length(p);
    x=abs(p((1:ceil(ls/2))));
    plot(hwin2,x)


    % if min(size(data))>1
    % error('Can''t load stereo data')
    % end

    end

    %is one of the function to call back for one of my uicontrol to load a wavfile and display the timewaveform (together with the envelope ) , frequency domain (spectrum) as well .
     
  8. johndoe45

    Member

    Jan 30, 2010
    364
    1
    so output variables are these [data,fs,smoothData]

    this is initial to final data points
    tdata = 1:ldata;

    so type ldata and will give you final pretty sure

    can't even find fs=...... in that mess
     
  9. BuriedMoon

    Thread Starter New Member

    Mar 2, 2010
    22
    0
    yes , indeed ..=)
     
  10. johndoe45

    Member

    Jan 30, 2010
    364
    1
    so you got it?

    and its correct for sure?

    cause it might be max(length(b)-1,length(a)-1)

    check this out and look at NOTE PORTION IN RECTANGULAR BOX!!!!!!!!!!!!!!!!!!
    http://www.mathworks.com/access/helpdesk/help/toolbox/signal/filtfilt.html

    but in your program i think that is the max height for first graph

    because you have plot(tdata,2*smoothData) so x is bottom and 2*smoothData is top
    there fore x axis is 1:ldata and y axis is -2*(max(length(b)-1,length(a)-1)):2*(max(length(b)-1,length(a)-1))
     
  11. BuriedMoon

    Thread Starter New Member

    Mar 2, 2010
    22
    0
  12. BuriedMoon

    Thread Starter New Member

    Mar 2, 2010
    22
    0
    It looks like 1data gives you the whole length of the data ...
     
  13. johndoe45

    Member

    Jan 30, 2010
    364
    1
    read my previous post.

    so want to achieve time?
     
  14. BuriedMoon

    Thread Starter New Member

    Mar 2, 2010
    22
    0
  15. johndoe45

    Member

    Jan 30, 2010
    364
    1
    i did. its same thing your doing except your version has n data points instead of time on bottoms. right?

    well attach your wav file if can or upload it to a website and post link, pm, something, email cause i have no idea what your talking about without running the program. never done this before
     
  16. BuriedMoon

    Thread Starter New Member

    Mar 2, 2010
    22
    0
    Yeah it is i suppose (sorry i'm pretty bad at MAtlab ) =(
     
  17. johndoe45

    Member

    Jan 30, 2010
    364
    1
    i only have like 3 months experience but have done lots of examples. read previous
     
  18. BuriedMoon

    Thread Starter New Member

    Mar 2, 2010
    22
    0
    Ok let me extract it and send it to you
     
  19. BuriedMoon

    Thread Starter New Member

    Mar 2, 2010
    22
    0
    Can you give me your email ?
     
  20. johndoe45

    Member

    Jan 30, 2010
    364
    1
    you send it to me yet? i think i sent you my email like 3 times cause doesn't show up under my sent messages

    when is this due. i'm tired. if can't figure it out in next ten minutes i'm probably going to bed.
     
Loading...