New perl program I am attempting - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

New perl program I am attempting

improvmanimprovman Posts: 3Member
Okay here is my dillema. Back in October of last year, I decided to take on a perl programming project for my science research project. Having no idea what Perl entailed, I plunged head-first into this project. Science fair is about a month and I need help on my project. It has nothing written to it yet, I just secured a computer that would run perl. anyway, Here are the params:
The program I am writing takes a recorded audio stream of a solo improvist and converts it into sheet music. The program takes the audio imput and breaks it down into individual seperate sound waves and measures the wavelength of those waves to determine its musical pitch. While the program measures the wavelength, it also measures the amount of time each wave was sustained and saves these values. (also measures empty space, where no sound was recorded)Once these values are recorded, the program's user selects the longest musical note length(half note etc.). This is applied to the longest recorded note time(i.e. 10 sec) since musical note length is scalar, with a margin of error, the proper note lengths can then be applied to all recorded notes. once this is completed, I need to know how I would import this processed information into an excel spread sheet or something so that the program will print out the information on scoresheets. Any help on this subject would be GREATLY appreciated.

Comments

  • JonathanJonathan Posts: 2,914Member
    : Okay here is my dillema. Back in October of last year, I decided to
    : take on a perl programming project for my science research project.
    : Having no idea what Perl entailed, I plunged head-first into this
    : project. Science fair is about a month and I need help on my
    : project. It has nothing written to it yet, I just secured a computer
    : that would run perl. anyway, Here are the params:
    Uh....oops. So why did you pick Perl? Sure, it's a great language and I greatly love working in it, but it certainly isn't the best tool for every job out there.

    : The program I am writing takes a recorded audio stream of a solo
    : improvist and converts it into sheet music.
    I hope you've done a preliminary study into the complexity of this problem, 'cus it ain't a simple one.

    : The program takes the audio imput and breaks it down into individual
    : seperate sound waves
    OK, so you're going to need to do FFT. Turns out there's a Perl module for that...wow...
    http://search.cpan.org/~rkobes/Math-FFT-0.25/FFT.pm
    Of course, you're going to need something more of a clue about FFT to use that module than I have.

    : and measures the wavelength of those waves to determine its musical
    : pitch.
    That part probably ain't so bad, if you've got the waves to look at. You'll probably want to concentrate on the "driving" wave rather than the other harmonics etc. That's what doing FFT should give you.

    : While the program measures the wavelength, it also measures the
    : amount of time each wave was sustained and saves these values. (also
    : measures empty space, where no sound was recorded)
    You may want to consider running the input through a noise gate to make this bit easier.

    : Once these values are recorded, the program's user selects the
    : longest musical note length(half note etc.). This is applied to the
    : longest recorded note time(i.e. 10 sec) since musical note length is
    : scalar, with a margin of error, the proper note lengths can then be
    : applied to all recorded notes.
    Sounds like a half decently through out algorithm...

    : once this is completed, I need to know how I would import this
    : processed information into an excel spread sheet or something so
    : that the program will print out the information on scoresheets.
    There's a module out there for helping you write excel spread sheet files:-
    http://search.cpan.org/author/JMCNAMARA/Spreadsheet-WriteExcel-0.42/WriteExcel.pm

    : Any help on this subject would be GREATLY appreciated.
    You got a HELL of a lot of work to do...good luck.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • improvmanimprovman Posts: 3Member
    : : Okay here is my dillema. Back in October of last year, I decided to
    : : take on a perl programming project for my science research project.
    : : Having no idea what Perl entailed, I plunged head-first into this
    : : project. Science fair is about a month and I need help on my
    : : project. It has nothing written to it yet, I just secured a computer
    : : that would run perl. anyway, Here are the params:
    : Uh....oops. So why did you pick Perl? Sure, it's a great language and I greatly love working in it, but it certainly isn't the best tool for every job out there.
    :
    : : The program I am writing takes a recorded audio stream of a solo
    : : improvist and converts it into sheet music.
    : I hope you've done a preliminary study into the complexity of this problem, 'cus it ain't a simple one.
    :
    : : The program takes the audio imput and breaks it down into individual
    : : seperate sound waves
    : OK, so you're going to need to do FFT. Turns out there's a Perl module for that...wow...
    : http://search.cpan.org/~rkobes/Math-FFT-0.25/FFT.pm
    : Of course, you're going to need something more of a clue about FFT to use that module than I have.
    :
    : : and measures the wavelength of those waves to determine its musical
    : : pitch.
    : That part probably ain't so bad, if you've got the waves to look at. You'll probably want to concentrate on the "driving" wave rather than the other harmonics etc. That's what doing FFT should give you.
    :
    : : While the program measures the wavelength, it also measures the
    : : amount of time each wave was sustained and saves these values. (also
    : : measures empty space, where no sound was recorded)
    : You may want to consider running the input through a noise gate to make this bit easier.
    :
    : : Once these values are recorded, the program's user selects the
    : : longest musical note length(half note etc.). This is applied to the
    : : longest recorded note time(i.e. 10 sec) since musical note length is
    : : scalar, with a margin of error, the proper note lengths can then be
    : : applied to all recorded notes.
    : Sounds like a half decently through out algorithm...
    :
    : : once this is completed, I need to know how I would import this
    : : processed information into an excel spread sheet or something so
    : : that the program will print out the information on scoresheets.
    : There's a module out there for helping you write excel spread sheet files:-
    : http://search.cpan.org/author/JMCNAMARA/Spreadsheet-WriteExcel-0.42/WriteExcel.pm
    :
    : : Any help on this subject would be GREATLY appreciated.
    : You got a HELL of a lot of work to do...good luck.
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :
    Thankyou for the links. greatly appreciated.
    ...And yeah, as I talk to more people, the problem of time is becoming evident. I'm thinkning of switching the program params a little. Instead of applying the waves to musical notes with length, I'm thinking of writing the program so that it just reads and processes the notes, and then applies it to a spreadsheet. By eliminating the time aspect I think I can make the program possible within the time constraints I have. What do you think?

  • JonathanJonathan Posts: 2,914Member
    : Thankyou for the links. greatly appreciated.
    No problem.

    : ...And yeah, as I talk to more people, the problem of time is
    : becoming evident. I'm thinkning of switching the program params a
    : little. Instead of applying the waves to musical notes with length,
    : I'm thinking of writing the program so that it just reads and
    : processes the notes, and then applies it to a spreadsheet. By
    : eliminating the time aspect I think I can make the program possible
    : within the time constraints I have. What do you think?
    Depends on your knowledge of the area and your programming experience too in part. If you're happy enough with the theory behind taking a waveform and analysing it then you're probably reasonably OK - you just have Perl language specifics to get used to. I've you've programmed much before that won't be too bad, and there'll be folks around here who can answer language questions. If you don't understand the theory...well, ouch.

    I guess how fast you can work figures into this somewhere too, and how things go - an couple of annoying bugs in a complex system can slow things down. Certainly, in this position, limiting the scope of the project is most likely a good idea though.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • improvmanimprovman Posts: 3Member
    Decided to use just a simple hash function. once the FFT breaks down the waves, I was going to import the wave pitch value into a key. for every individual wave I would then return a letter value. i.e. My_hash {440} = A #and such.
    Then I was going to have to program place these values into list. once the list is completed, I was then going to have the program put the list into a text document or an excel sheet. Mine only questions are "what do I need to do to have the broken down wave values import themselves into the Key space?" then, "what do I need to do to store the return values into a list, and how does one put the list into a text document.(think I'm going to stick with a text document.)
    If you have some free time and don't mind, help would be appreciated.

    e^(x^2)...integrate me !
  • JonathanJonathan Posts: 2,914Member
    : Decided to use just a simple hash function. once the FFT breaks down
    : the waves, I was going to import the wave pitch value into a key.
    : for every individual wave I would then return a letter value. i.e.
    : My_hash {440} = A #and such.
    You might want to think about rounding these values to the nearest pitch that has a hash entry. This is fairly easily done with something like:-

    [code]# Imagine that we have the frequency in $freq, and that
    # $note will contain the note from the frequencies hash
    # set up like you described.
    my $curfreq = my $lastfreq = 0;
    foreach $curfreq (sort keys %notehash) {
    # See if we're in the right range.
    if ($freq >= $lastfreq && $freq < $curfreq) {
    # See which one it's closest to.
    if (($freq - $lastfreq) < ($curfreq - $freq)) {
    $note = $notehash{$lastfreq};
    } else {
    $note = $notehash{$curfreq};
    }
    }
    # Store this frequency.
    $lastfreq = $curfreq;
    }[/code]

    : Then I was going to have to program place these values into list.
    : once the list is completed, I was then going to have the program put
    : the list into a text document or an excel sheet.
    I'm thinking a pure list will not be what you really want because you want note and duration. Maybe two lists with sync'd indexes, or an array of hashrefs and use the hashes for info, e.g.

    [code]push @song, {
    note => $note,
    duration => $duration
    };[/code]

    To add the entry for the latest note.

    : Mine only questions are "what do I need to do to have the broken
    : down wave values import themselves into the Key space?"
    See above example, which I hope gets at what you mean. You need to do that in a loop though, for each frequency value you have. I don't know how you're getting the data so it's not all that easy to give you a really good solution.

    : then, "what do I need to do to store the return values into a list,
    : and how does one put the list into a text document.(think I'm going
    : to stick with a text document.)
    That's what the second bit of code is for. Once you have the list, you can write it to a text document, HTML document, or Excel sheet (your original plan IIRC - there is a module for doing Excel sheets).

    : If you have some free time and don't mind, help would be appreciated.
    Hope this helps, though I'm not sure it will.

    : e^(x^2)...integrate me !
    Sure, if you give me some limits and using Euler's improved algorithm for numerical integrations counts. :-)

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.