Little Parsing help...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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        Em
This is the first line of my song
         C/E      Em7            Dm7
and I know it can get real long
         Gm7          Am7
If you know I will say
                 G/B                    C
That 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        Em
This is the first line of my song
*         C/E      Em7            Dm7
and I know it can get real long
*         Gm7          Am7
If you know I will say
*                 G/B                    C
That 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        Fm
This is the first line of my song
*         C#/F      Fm7            D#m7
and I know it can get real long
*         G#m7          A#m7
If 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#m
This is the first line of my song
*         B/D#      D#m7            C#m7
and I know it can get real long
*         F#m7          G#m7
If you know I will say
*                 F#/A#                    B
That 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux