Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Programmers' lounge. (Programming-related discussions only)
New Posts  All Forums:Forum Nav:

Programmers' lounge. (Programming-related discussions only) - Page 96

post #951 of 957
Hi guys, I have a question. so my girlfriend really needs my help with a project for the national science fair and I'm not sure how i can help her. She wants me to write a program that reads music,(sheet music) assigns each note a number, and at the end of each line of music all of the numbers will be added. I know how to do the summation but I don't know how to get the program to "read" the music.
The Tigress
(17 items)
 
 
CPUMotherboardGraphicsRAM
Intel Pentium G3258 Gigabyte Z97 SOC BFGTech GTX 260 Kingston Hyper X Blue 
RAMHard DriveHard DriveHard Drive
G. Skill Ripjaws X Western Digital Blue Samsung HD501 Seagate Momentus 
CoolingOSMonitorMonitor
Cooler Master Hyper212+ Windows 8.1 32" Sony Bravia at 108p 21" HP 2011X at 1600x900 
KeyboardPowerCaseMouse
Microsoft Sidewinder X4 Corsair HX 750 NZXT Phantom Orange and Black Razer Naga Molten 
Audio
Corsair Vengeance 1500 
  hide details  
Reply
The Tigress
(17 items)
 
 
CPUMotherboardGraphicsRAM
Intel Pentium G3258 Gigabyte Z97 SOC BFGTech GTX 260 Kingston Hyper X Blue 
RAMHard DriveHard DriveHard Drive
G. Skill Ripjaws X Western Digital Blue Samsung HD501 Seagate Momentus 
CoolingOSMonitorMonitor
Cooler Master Hyper212+ Windows 8.1 32" Sony Bravia at 108p 21" HP 2011X at 1600x900 
KeyboardPowerCaseMouse
Microsoft Sidewinder X4 Corsair HX 750 NZXT Phantom Orange and Black Razer Naga Molten 
Audio
Corsair Vengeance 1500 
  hide details  
Reply
post #952 of 957
Quote:
Originally Posted by Nomadskid View Post

Hi guys, I have a question. so my girlfriend really needs my help with a project for the national science fair and I'm not sure how i can help her. She wants me to write a program that reads music,(sheet music) assigns each note a number, and at the end of each line of music all of the numbers will be added. I know how to do the summation but I don't know how to get the program to "read" the music.

That's a lot harder than it sounds. How good is your coding skills and what format is the sheet music currently stored in?
post #953 of 957
Quote:
Originally Posted by Plan9 View Post

That's a lot harder than it sounds. How good is your coding skills and what format is the sheet music currently stored in?
I can scan the music to be in a pdf. And I am fairly decent at coding.
The Tigress
(17 items)
 
 
CPUMotherboardGraphicsRAM
Intel Pentium G3258 Gigabyte Z97 SOC BFGTech GTX 260 Kingston Hyper X Blue 
RAMHard DriveHard DriveHard Drive
G. Skill Ripjaws X Western Digital Blue Samsung HD501 Seagate Momentus 
CoolingOSMonitorMonitor
Cooler Master Hyper212+ Windows 8.1 32" Sony Bravia at 108p 21" HP 2011X at 1600x900 
KeyboardPowerCaseMouse
Microsoft Sidewinder X4 Corsair HX 750 NZXT Phantom Orange and Black Razer Naga Molten 
Audio
Corsair Vengeance 1500 
  hide details  
Reply
The Tigress
(17 items)
 
 
CPUMotherboardGraphicsRAM
Intel Pentium G3258 Gigabyte Z97 SOC BFGTech GTX 260 Kingston Hyper X Blue 
RAMHard DriveHard DriveHard Drive
G. Skill Ripjaws X Western Digital Blue Samsung HD501 Seagate Momentus 
CoolingOSMonitorMonitor
Cooler Master Hyper212+ Windows 8.1 32" Sony Bravia at 108p 21" HP 2011X at 1600x900 
KeyboardPowerCaseMouse
Microsoft Sidewinder X4 Corsair HX 750 NZXT Phantom Orange and Black Razer Naga Molten 
Audio
Corsair Vengeance 1500 
  hide details  
Reply
post #954 of 957
Quote:
Originally Posted by Nomadskid View Post

I can scan the music to be in a pdf. And I am fairly decent at coding.
I'm not really sure PDF is the best format for this. You could probably use a bitmap and scan for pixel colour changes, along each row. But you'd need to ensure that your sheet music is horizontally aligned perfectly for that to work (since you're scanning your sheet music in). There's also a whole boat load of other issues with the more complicated notations. So I couldn't see this being practical by any means.

If you can find the scores you're after in MusicXML format (http://en.wikipedia.org/wiki/MusicXML) then it might be a "trivial" case of parsing an XML file.
post #955 of 957
Quote:
Originally Posted by Plan9 View Post

I'm not really sure PDF is the best format for this. You could probably use a bitmap and scan for pixel colour changes, along each row. But you'd need to ensure that your sheet music is horizontally aligned perfectly for that to work (since you're scanning your sheet music in). There's also a whole boat load of other issues with the more complicated notations. So I couldn't see this being practical by any means.

If you can find the scores you're after in MusicXML format (http://en.wikipedia.org/wiki/MusicXML) then it might be a "trivial" case of parsing an XML file.
I can use xml if need be I'm just not sure where to start.
The Tigress
(17 items)
 
 
CPUMotherboardGraphicsRAM
Intel Pentium G3258 Gigabyte Z97 SOC BFGTech GTX 260 Kingston Hyper X Blue 
RAMHard DriveHard DriveHard Drive
G. Skill Ripjaws X Western Digital Blue Samsung HD501 Seagate Momentus 
CoolingOSMonitorMonitor
Cooler Master Hyper212+ Windows 8.1 32" Sony Bravia at 108p 21" HP 2011X at 1600x900 
KeyboardPowerCaseMouse
Microsoft Sidewinder X4 Corsair HX 750 NZXT Phantom Orange and Black Razer Naga Molten 
Audio
Corsair Vengeance 1500 
  hide details  
Reply
The Tigress
(17 items)
 
 
CPUMotherboardGraphicsRAM
Intel Pentium G3258 Gigabyte Z97 SOC BFGTech GTX 260 Kingston Hyper X Blue 
RAMHard DriveHard DriveHard Drive
G. Skill Ripjaws X Western Digital Blue Samsung HD501 Seagate Momentus 
CoolingOSMonitorMonitor
Cooler Master Hyper212+ Windows 8.1 32" Sony Bravia at 108p 21" HP 2011X at 1600x900 
KeyboardPowerCaseMouse
Microsoft Sidewinder X4 Corsair HX 750 NZXT Phantom Orange and Black Razer Naga Molten 
Audio
Corsair Vengeance 1500 
  hide details  
Reply
post #956 of 957
Quote:
Originally Posted by Nomadskid View Post

I can use xml if need be I'm just not sure where to start.

Well I answered that question already tongue.gif
  1. Find the music scores in MusicXML format,
  2. look at the specification for MusicXML (there's a basic introduction to it on the link I gave, but I'd recommend you do a little more digging for a proper spec)
  3. and then use the standard XML parsing libraries that your programming language of preference supports.

Since this is a school project, I don't really want to be writing the code for you, but you said you were fairly decent at coding anyway so this shouldn't be too difficult (the hardest bit is the XML parsing but you shouldn't need to do that manually anyway)

edit:
Just to add, I've found the superman theme: http://musescore.com/user/45603/scores/130897 this site supports MusicXML (*.mxl) so that looks a good place to find your scores. Just be mindful that, like OOXML, those files are zip archives with XML content. So you may have to cheat and extract the archives manually (you can do it programmatically if you really want, but I'm just trying to save you time).
Edited by Plan9 - 10/11/14 at 3:21pm
post #957 of 957
So I've been implementing the sieve algorithm to find primes and I wrote this code:
Code:
#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector <int> primes;
    int theLimit = 10E6;

    void sieve (vector <int> &primes, int theLimit);
    sieve (primes, theLimit);

    for (int i = 0; i < primes.size(); ++i){
        cout << primes[i] << "\n";
    }

    return 0;
}

void sieve (vector <int> &primes, int theLimit) {
    const int SIZE = theLimit;
    bool oddNonPrimes [SIZE];

    for (int i = 3; i < theLimit; i += 2){
        if (!oddNonPrimes[i]){
            int currNum = i;
            primes.push_back(currNum);
            for (int factor = 2; currNum <= theLimit; ++factor){
                currNum *= factor;
                oddNonPrimes[currNum] = true;
                currNum = i;
            }
        }
    }

}

But I'll get a "segementation fault (core dumped)" error which I belive is because I'm trying to access a value that isn't there (the "oddNonPrimes" is not set to anything(?)),so my question is:Is there anyway to set the entire bool array to false WITHOUT having to step into each index individually and setting it to false?if so,how?

Edit:turns out it's not because the array is not set to false (I've tried to do that with a loop and still got the same error),it seems to give me this error whenever I try to access the array to read or write,which is weird.Could it be a compiler error?

Edited by ABD EL HAMEED - Today at 2:33 pm
My First
(9 items)
 
My dream
(7 items)
 
 
CPUMotherboardGraphicsGraphics
i7 4960x ASUS Rampage IV Extreme Black Edition GTX 780 ti GTX 780 ti 
GraphicsRAMHard Drive
GTX 780 ti  64 GB corsair dominator Samsung 840 pro 256GB SSD 
  hide details  
Reply
My First
(9 items)
 
My dream
(7 items)
 
 
CPUMotherboardGraphicsGraphics
i7 4960x ASUS Rampage IV Extreme Black Edition GTX 780 ti GTX 780 ti 
GraphicsRAMHard Drive
GTX 780 ti  64 GB corsair dominator Samsung 840 pro 256GB SSD 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Programmers' lounge. (Programming-related discussions only)