Results 1 to 8 of 8

Thread: Best Fit Curve [RESOLVED]

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Resolved Best Fit Curve [RESOLVED]

    I want to make a program that will fix a distorted sound, it is not any type sound, it is a tone (which actually makes things easier)

    When the sound is too loud, it will be cut off.
    I want to decrease the sound volume, and complete (by approximation) the parts that are missing.

    I searched on google for "best fit curve", I have found programs that do this, but not for sounds, and I didn't find any source code.

    What I want is to have a function where I give the points that I have (that are valid), and I want it to complete the rest of the points based on the points i'm giving it.

    If you look at the attached picture you will have a better idea.
    The top wave, is the distorted one, and the bottom, is one where I manually fixed one of the "bumps" of the sound.

    the part in between the 2 vertical lines is the part where the function should complete.
    I want to give the function a few points that are before the left line, and a few points after the right line.

    I also found on the internet formulas to do it, but I'm not that good at math (grade 12 math is the last one I took, in coledge math is not required ), I was hoping that someone might explain to me how to do it in a programming way.

    Any idea on how to do this ?
    Please help...

    Thank You.
    Attached Images Attached Images  
    Last edited by CVMichael; Mar 16th, 2005 at 07:34 PM.

  2. #2
    Addicted Member Rassis's Avatar
    Join Date
    Jun 2004
    Location
    Lisbon
    Posts
    248

    Re: Best Fit Curve

    Hi,

    A polynomial function of second or perhaps third degree can be approximated by the least squares method. The algorithm is rather complex but I know how to do it in Excel. Does it suit you?
    ...este projecto dos Deuses que os homens teimam em arruinar...

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Best Fit Curve

    Sure, explain to me how it's done ?

    Also if you could explain in a way that i may put it in programming, sometimes math formulas are difficult to put in programming.

    If i don't understand it, I have a friend that's much better than me in math, most likely he will understand it.

    Thanks

  4. #4
    Addicted Member Rassis's Avatar
    Join Date
    Jun 2004
    Location
    Lisbon
    Posts
    248

    Smile Re: Best Fit Curve

    Hi Michael,

    It is impossible to explain in this forum how to handle polynomial regression. Please take a look at the attached spreadsheet and these sites:

    http://home.ubalt.edu/ntsbarsh/Busin.../PolynoReg.htm
    http://www.nlreg.com/
    http://www.statsoft.com/textbook/stathome.html

    Hope this helps.

    I have been to Vancouver a few years ago together with my wife and travelled through British Columbia and Alberta states. It was just marvellous. Nice cities, nice people and spectacular landscapes. You are lucky.
    Attached Files Attached Files
    ...este projecto dos Deuses que os homens teimam em arruinar...

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Best Fit Curve

    Thank you for the links, and the Excel example.

    It seems that what I need now is to find out how LINEST is calculated. Once I get the 3 numbers (a & b & c), I can draw the Polinomial Regression.

    I looked up on the internet and I can't find anything, I have to code it in Visual Basic, and also in C/C++

    In Visual Basic, I can create an Excel object, and just call the LinEst function, but if i do it in C++, I can't, I have to re-invent the wheel, and actually create the LinEst function.

    Do you know how LINEST is calculated ?

    Thanks

  6. #6
    Addicted Member Rassis's Avatar
    Join Date
    Jun 2004
    Location
    Lisbon
    Posts
    248

    Re: Best Fit Curve

    I am sorry but I don´t know how the LINEST function is calculated. I only use it in MS-Excel. I like maths (mainly stats) and I use it a lot in my professional life, but I am not well acquainted with coding.

    I am afraid you will have to "reivent the wheel" starting with the maths on the polinomial regression, unless you get help from other peers in the mean time.

    Hope you manage.
    ...este projecto dos Deuses que os homens teimam em arruinar...

  7. #7
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Best Fit Curve

    Thank you yrwyddfa, that link solved my problem
    Rassis, thank you to you also, for helping me...

    Finally, I got it to work, I had to do a little more than what is in the link provided by yrwyddfa.

    Now I can fix sounds (Tones) that are over-amplified up to 6 TIMES, and it will still fix it back.
    Last edited by CVMichael; Mar 16th, 2005 at 07:33 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width