On 1 October 2010 14:35, Don Wieland <donw@xxxxxxxxxxxxx> wrote: > 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 > > For each key I would guess you'd need the chord order, so if you change key, you change chords accordingly. I don't know if that is accurate. If it is, then a song is recorded in a particular key. The song will then play the chords/notes of that key. Key1, Note1, Note2, Note2, Note3, Note4, Note1. Change key, the same notes are played. For that key ... Key2, Note1, Note2, Note2, Note3, Note4, Note1. Or Key4, Note1, Note2, Note2, Note3, Note4, Note1. If this is the same for chords, then I'd go with : A Key table (ID, Keyname) - all the names of the keys A Notes table (ID, KeyID, Note, Sequence) - the notes in order per key with a unique composite key of KeyID+Sequence A Song table (ID, NormalKeyID, Title) - the key that the song is normally sung in. A Song Notes table (ID, SongID, NoteSequenceNumber) - Which notes are played. Changing the NormalKeyID and using that ID with NoteSequenceNumber should give you the new note to play. I think. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php