Results 1 to 3 of 3
  1. #1
    herpeslurpy is offline Member
    Join Date
    Nov 2012
    Posts
    40
    Rep Power
    0

    Default Help looping a guitar tab converter

    I play the guitar (poorly), and I came up with the idea of a program that converts guitar tabs to normal notes. So I wrote it up at school today, and it works just fine, but it only converts one note and then terminates. I'd like to get it to loop as much as I want, but I'm having trouble getting it to work with how I have it set up.

    Java Code:
    import java.util.*; 
    public class Converter { 
        public static void main(String[] args) { 
            Scanner input = new Scanner(System.in); 
            String note = ":"; 
            String finalNote; 
            int end; 
            int start; 
            int fret;  
            String[] notes = {"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"}; 
            
    
            while(note.contains(":")){  
            	note = input.nextLine(); 
            	String[] array = note.split(":"); 
            	fret = Integer.parseInt(array[1]);  
            	switch(array[0]){ 
                case "e": 
                    start = 7; 
                    end = start + fret; 
                    if(end >= 12){ 
                        fret = fret - 12; 
                    } 
                    end = start + fret; 
                    finalNote = notes[end]; 
                    System.out.println(finalNote); 
                    break; 
                case "a": 
                    start = 0; 
                    end = start + fret; 
                    if(end >= 12){ 
                        fret = fret - 12; 
                    } 
                    end = start + fret; 
                    finalNote = notes[end]; 
                    System.out.println(finalNote); 
                    break; 
                case "d": 
                    start = 5; 
                    end = start + fret; 
                    if(end >= 12){ 
                        fret = fret - 12; 
                    } 
                    end = start + fret; 
                    finalNote = notes[end]; 
                    System.out.println(finalNote); 
                    break; 
                case "g": 
                    start = 10; 
                    end = start + fret; 
                    if(end >= 12){ 
                        fret = fret - 12; 
                    } 
                    end = start + fret; 
                    finalNote = notes[end]; 
                    System.out.println(finalNote); 
                    break; 
                case "b": 
                    start = 2; 
                    end = start + fret; 
                    if(end >= 12){ 
                        fret = fret - 12; 
                    } 
                    end = start + fret; 
                    finalNote = notes[end]; 
                    System.out.println(finalNote); 
                    break; 
                case "highE": 
                    start = 7; 
                    end = start + fret; 
                    if(end >= 12){ 
                        fret = fret - 12; 
                    } 
                    end = start + fret; 
                    finalNote = notes[end]; 
                    System.out.println(finalNote); 
                    break; 
                default: 
                    System.out.println("You need to select a string"); 
                    System.exit(0); 
                    break; 
            		}
            	}
            input.close();     
        	}   
    	}
    I have it set up with a while loop at the top of the switch, to look for a character in the string entered to convert a note. The program takes input as a base note (Basically an open string), and the fret being used, with a colon in between. That input is then split into the string, which is figured out in the cases, and the fret number. The converted note is basically figured out by where the base note is in an array with all 12 possible notes, and adding the fret number to it. i.e: an e string with the 5 fret, would be seen as the 8 index, then the fret number is added to find a new spot in the index, which is the new converted note. If the new note's place is higher than the index goes, it starts a new set of notes, like in normal music.
    So, I have it set to detect the colon in each entry, and if there isn't one, it should then terminate the program. I'm having trouble figuring out how to correctly loop it with the conditions to stop. So if anyone has any ideas, I'd appreciate the help.
    Last edited by herpeslurpy; 09-14-2013 at 01:13 AM.

  2. #2
    herpeslurpy is offline Member
    Join Date
    Nov 2012
    Posts
    40
    Rep Power
    0

    Default Re: Help looping a guitar tab converter

    Sorry guys, I just figured it out. I had been putting an If at the end of the loop to look for the ':', I put it right after the input and it works like a charm. But, I have been planning to add some new things, like multiple tuning supports, if different tunings are used. And maybe a couple other ideas. If anyone has any ideas, feel free to contribute.

  3. #3
    herpeslurpy is offline Member
    Join Date
    Nov 2012
    Posts
    40
    Rep Power
    0

    Default Re: Help looping a guitar tab converter

    I just added support for every note, so I suppose that one's off the list

Similar Threads

  1. Guitar Trainer 1.1.4
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 07-11-2008, 03:55 PM
  2. Guitar Trainer 1.1.3
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 06-26-2008, 07:17 PM
  3. Guitar Trainer 1.1.2
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 04-22-2008, 05:25 PM
  4. Guitar Trainer 1.0.11
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 10-27-2007, 08:35 PM
  5. Guitar Trainer 1.0.4
    By levent in forum Java Software
    Replies: 0
    Last Post: 06-10-2007, 02:41 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
  •