Music Intervals
eharetea

Combining programming and music through intervals.

Intervals in music, now in C.

Date Created:Saturday August 02nd, 2008 02:47 PM
Date Modified:Saturday August 02nd, 2008 02:51 PM


/*
* Author: Dan Lynch
*/

#include <stdio.h>

/* Function Prototypes */
void enternumber(int *x);
void printint(int x);
char *return_note_name(int x);
void array_handler();
char *return_position(int x);
int scale();

int main()
{
    int sizenote, array[12] = {1,1,1,1,1,1,1,1,1,1,1,1};
    
    //enter a value
    enternumber(&note);
    
    
    //printint(note);
    printf("%s\n"return_note_name(note));
    
    
    
    // print out the array!
    size 12;
    array_handler(1,&array, size);
    
    //print the position from the root
    printf("%s\n"return_position(note) );;
    
    //call for a scale
    scale(&array, size);
    
    //print array
    array_handler(1,&array, size);
    
    return 0;
}







/*
*
*
*
* Functions
*
*
*
**/


void enternumber(int *x) {
    printf("Enter a number between 1-88\n");
    scanf("%d"x);
}

void printint(int x) {
    printf("%d\n"x);
}

void array_handler(int whatFuncint *array, int size)
{
    int i;
    for (i=0;i<size;i++) printf("%d\n", array[i]);
}

int scale(int *Vint sizeint scaletype)
{
    int majorscale[12] = {0,0,1,0,1,0,0,1,0,1,0,1};
    int minorscale[12] = {0,0,1,0,0,1,0,1,0,1,0,1};
    int x;

    for (x=0x<size-1;x++) {
        if ( scaletype == V[x] += majorscale[x];
        if ( scaletype == V[x] += minorscale[x];
    }
    return 0;
}


char *return_note_name(int x)
{
    static char note_name[12][6] = {     
                {"A"},
                {"A#/Bb"},
                {"B"},
                {"C"},
                {"C#/Db"},
                {"D"},
                {"D#/Eb"},
                {"E"},
                {"F"},
                {"F#/Gb"},
                {"G"},
                {"G#/Ab"}
                };
    return note_name[x%12];
}


char *return_position(int x)
{
    static char interval[25][40] = {
                {"Perfect Unison"},
                {"minor 2nd"},
                {"Major 2nd"},
                {"Augumented 2nd/minor 3rd"},
                {"Major 3rd"},
                {"Perfect 4th"},
                {"Augumented 4th/Diminished 5th"},
                {"Perfect 5th"},
                {"Augumented 5th/Diminished 6th"},
                {"Diminished 7th/Major 6th"},
                {"minor 7th"},
                {"Major 7th"},
                {"Octave"},
                {"minor 9th"},
                {"major 9th"},
                {"Augmented 9th"},
                {"Major 10th"},
                {"Perfect 11th"},
                {"Augumented 11th"},
                {"Perfect 12th"},
                {"Augumented 12th"},
                {"Major 13th"},
                {"minor 14th"},
                {"Major 14th"},
                {"Perfect 15th"}
                };
                return interval[x];
}                



Downloads:
Download: intervals2.c 2 KB

Please login or Click Here to register for downloads
Creative Commons License
Music Intervals by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com