Little Parsing help...
| From: | Don Wieland | Date: | Fri, 01 Oct 2010 13:35:44 +0000 |
| Subject: | Little Parsing help... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-308381@lists.php.net to get a copy of this message | ||
Hello,
I am building a web Song DB. That will simple song chord charts in the DB. I would like the ability to do KEY changes for the different songs. I am looking for some direction on how to do this. This was my original thought but I am open if there is a better way.
I defined a table called Chords (here is the mySQL Dump):
DROP TABLE IF EXISTS
Chords;
CREATE TABLE Chords (
id int(11) NOT NULL auto_increment,
original_note varchar(2) default NULL,
up_note varchar(2) default NULL,
down_note varchar(2) default NULL,
flatted varchar(2) default NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;
LOCK TABLES Chords WRITE;
/*!40000 ALTER TABLE Chords DISABLE KEYS */;
INSERT INTO Chords (id,original_note,up_note,down_note,flatted)
VALUES
(1,'A','A#','G#',NULL),
(2,'A#','B','A','Bb'),
(3,'B','C','A#',NULL),
(4,'C','C#','B',NULL),
(5,'C#','D','C','Db'),
(6,'D','D#','C#',NULL),
(7,'D#','E','D','Eb'),
(8,'E','F','D#',NULL),
(9,'F','F#','E',''),
(10,'F#','G','F','Gb'),
(11,'G','G#','F#',NULL),
(12,'G#','A','G','Ab');
/*!40000 ALTER TABLE Chords ENABLE KEYS */;
UNLOCK TABLES;
---------------
now this is a sample of my Music Charts:
C Dm7 EmThis is the first line of my song
C/E Em7 Dm7and I know it can get real long
Gm7 Am7If you know I will say
G/B CThat it will help to ease the day What I was hoping for is to check patterns in the CHORD LINES. I realize I need to mark which lines do PHP will now which line to parse. I was thinking that the user would add a asterisk "*" at the beginning of the chord line like so:
* C Dm7 EmThis is the first line of my song
* C/E Em7 Dm7and I know it can get real long
* Gm7 Am7If you know I will say
* G/B CThat it will help to ease the day Then have PHP look for occurrences in the lines that begin with an "*". So if I want to transpose up 1/2 step, it would look like this:
* C# D#m7 FmThis is the first line of my song
* C#/F Fm7 D#m7and I know it can get real long
* G#m7 A#m7If you know I will say
* G#/C C#That it will help to ease the day So if I want to transpose up 1/2 step, it would look like this:
* B C#m7 D#mThis is the first line of my song
* B/D# D#m7 C#m7and I know it can get real long
* F#m7 G#m7If you know I will say
* F#/A# BThat it will help to ease the day I guess the challenge would that once the value was changed, it would not get changed again it same process. Also, I need to make sure that EXACT Case is only changed. For example, there might be a chord like "Asus add 9" where I would not want the "a" of add9 to change. Any suggestions would be appreciated. Don Wieland