Ok, lads, here is my first patch, just to check if I was not wrong with my
keyboard tonight. This adds a "Genre" column, and extract genre from MP3 and
ogg files and stores it in the mixxxtracks.xml file.

Gaetan

2008/5/28 Gaetan <[EMAIL PROTECTED]>:

> noted :)
>
>
> 2008/5/28 Garth Dahlstrom <[EMAIL PROTECTED]>:
>
>>
>> The sort indicator would have you believe that...   In fact, it's not
>> sorted in any particular way (just whatever order it was read from
>> .mixxxtracks.xml), if you click on the sort indicator twice you'll get real
>> sorted data... :D
>>
>> Screenshot is what my library looks at start-up...
>>
>>
>> On Tue, May 27, 2008 at 7:24 PM, Gaetan <[EMAIL PROTECTED]> wrote:
>>
>>> Hi
>>> I don't understand your suggestion. The library is sorted by artist by
>>> default on startup. Could you please elaborate a bit more?
>>>
>>> Gaetan
>>>
>>> 2008/5/28 Garth Dahlstrom <[EMAIL PROTECTED]>:
>>>
>>> Hi Gaetan,
>>>>
>>>> As a challenge to get to know the library code better, you could start
>>>> by having a go at making the library 'sort by artist' on start-up....
>>>>
>>>> I would expect the fix to be quite small for that, but where to apply it
>>>> would be the interesting part.  It would be a nice bit of polish for the
>>>> release too. ;)
>>>>
>>>> Cheers,
>>>>
>>>> -G
>>>>
>>>>
>>>> On Tue, May 27, 2008 at 3:31 PM, Gaetan <[EMAIL PROTECTED]> wrote:
>>>>
>>>>> Thanks for your feedback!
>>>>>
>>>>> I've started this page on the wiki :
>>>>> http://mixxx.org/wiki/doku.php/playqueue_and_library_improvements_proposals
>>>>> I'll study the code and try to perform some hacks.
>>>>>
>>>>> Gaetan
>>>>>
>>>>> 2008/5/27 Albert James Santoni <[EMAIL PROTECTED]>:
>>>>>
>>>>> Hi Gaetan,
>>>>>>
>>>>>> Replies inline below:
>>>>>>
>>>>>> ----- Original Message -----
>>>>>> From: Gaetan <[EMAIL PROTECTED]>
>>>>>> Date: Tuesday, May 27, 2008 11:31 am
>>>>>> Subject: [Mixxx-devel] Willing to contribute to mixxx project
>>>>>> To: [email protected]
>>>>>>
>>>>>> > Hello
>>>>>> >
>>>>>> > I've sent this message to the forum just before discovering this
>>>>>> mailing list...
>>>>>> > so here is my proposal.
>>>>>> >
>>>>>> > --
>>>>>> >
>>>>>> > Having quite a strong experience in C
>>>>>> > and C++ on linux, but not much with such large projects, I would
>>>>>> like
>>>>>> > to contribute to the mixxx project on a few weakness I've
>>>>>> > noticed. I
>>>>>> > would like to improve the playlist, Play Queue and Library, and
>>>>>> > I would
>>>>>> > really appreciate some advices on how to begin, coding rules, best
>>>>>> > practice for patch submission, where to start hacking, etc.
>>>>>> >
>>>>>>
>>>>>> Welcome aboard! We're always looking for more help coding, so we'd be
>>>>>> happy to do everything we can to get you started. There's definitely room
>>>>>> for improvement to the library interface, and I'm glad you're interested 
>>>>>> in
>>>>>> working on it.
>>>>>>
>>>>>> > Do
>>>>>> > I have to draw a sketch of my plan, describe it somewhere,
>>>>>> > discuss it
>>>>>> > here, rise a ticket for this in a bugzilla, etc or just start
>>>>>> hacking
>>>>>> > as soon as possible and submit the patch? How can I be sure it
>>>>>> > will fit
>>>>>> > with current mixxx roadmap and be integrated?
>>>>>>
>>>>>> Depends on what you want to do. If you're thinking about writing some
>>>>>> big feature, then the steps are:
>>>>>> - Describe it on mixxx-devel and ask for ideas/feedback
>>>>>> - Write a specification in the wiki so that's it clear what you're
>>>>>> going to do. (The more thinking you do before you code, the easier it is 
>>>>>> to
>>>>>> code.) :)
>>>>>> - Code!
>>>>>>
>>>>>> If you just want to do a bug fix or something small, just code it and
>>>>>> email a patch to this mailing list. To ensure your work will fit in with 
>>>>>> the
>>>>>> current roadmap and be integrated, just ask! (This is why writing a
>>>>>> specification is good too.) Our current release status is we're trying to
>>>>>> wrap up 1.6.0, and so our focus is going to be on fixing these remaining
>>>>>> bugs:
>>>>>> https://bugs.launchpad.net/mixxx/1.6/+bugs
>>>>>>
>>>>>> If you make bug fixes to the library (eg. the play queue sorting),
>>>>>> we'll have no problem putting them in trunk. If you add features (eg. 
>>>>>> song
>>>>>> ratings), then we should probably throw them in a branch until the 1.6.0
>>>>>> release is done.
>>>>>>
>>>>>> >
>>>>>> > What I wish to improve are (sorted according to my own, humble
>>>>>> > needs) :
>>>>>> > 1)
>>>>>> > change the Play Queue window so the list is sorted according to the
>>>>>> > play sequence (and not the alphabetical order of the title), and
>>>>>> allow
>>>>>> > DJ to reorganise this play queue.
>>>>>>
>>>>>> Yeah, something like this would make the play queue a lot better.
>>>>>>
>>>>>> > 2) double click on a track start
>>>>>> > imediatly the playback on the first headset configured table (if no
>>>>>> > headset is set, do nothing). No need to do "stop",
>>>>>> > double click on a
>>>>>> > track, "play". I'm lazy...
>>>>>>
>>>>>> Doesn't "NEXT" mode do this already? (I think I misunderstand...)
>>>>>>
>>>>>> > 3) Display a little tag on any already
>>>>>> > played track in Playlist, Browse and Library view (to prevent
>>>>>> choosing
>>>>>> > several time the same track during one session), or a "last
>>>>>> > played"date column.
>>>>>> > 4) Display a column in Library and Browse with the
>>>>>> > Genre ID3 tag; I'm using it to sort my collection by
>>>>>> > different music
>>>>>> > genre (Salsa, rock, Bachata, Soul, RnB, Rap,...)
>>>>>>
>>>>>> These should be do-able...
>>>>>>
>>>>>> > 5) I'm rating my
>>>>>> > mp3s with Amarok, so I'll try to change it as well so the
>>>>>> > rating value
>>>>>> > will be inserted in the file itself (as an extended ID3 tag),
>>>>>> > and make
>>>>>> > mixxx import/sync with this tag. it would be perfect to easily
>>>>>> display
>>>>>> > best musics to the user.
>>>>>>
>>>>>> Mixxx doesn't have ID3/ogg writing support, so this will take some
>>>>>> work.
>>>>>>
>>>>>> > 6) (don't know how to do this but this
>>>>>> > would definitively rocks) Implements a Facet view for the
>>>>>> > "Library"view (you know, three column
>>>>>> > Genre/Artist/Album like in rythmbox)
>>>>>>
>>>>>> Some people have requested alternate library views. This might be a
>>>>>> lot of work too, and would definitely be something worth discussing 
>>>>>> later.
>>>>>>
>>>>>> In the meantime, I would start on something simple like fixing the
>>>>>> play queue ordering. For all the library stuff, the central source file 
>>>>>> is
>>>>>> "src/track.cpp" (the "Track" class should really be called "Library", 
>>>>>> it's
>>>>>> confusing). The play queue is just a playlist called m_qPlayQueue or
>>>>>> something in the Track class. I forget how the play queue view works off 
>>>>>> the
>>>>>> top of my head, but our library code uses QT's model/view paradigm.
>>>>>>
>>>>>> Also note, each song is represented internally by a "TrackInfoObject"
>>>>>> (src/trackinfoobject.cpp).
>>>>>>
>>>>>> >
>>>>>> > I
>>>>>> > would really appreciate any hint on these items, where is the best
>>>>>> > place in the code to perform the changes, if there is simple way of
>>>>>> > doing this, ...
>>>>>> >
>>>>>> > or if they are bad ideas...
>>>>>>
>>>>>> Most of these are reasonable ideas, but I would definitely start with
>>>>>> bug fixing. Trying to fix something that bugs you is a good way to learn
>>>>>> Mixxx's library code. :)
>>>>>>
>>>>>> >
>>>>>> > But first... how can I extract the latest 1.6.x SVN version so I
>>>>>> > can start hacking it tonight? (I only know svn to extract latest
>>>>>> > trunk version).
>>>>>> > Thanks!
>>>>>>
>>>>>> Trunk is the latest 1.6.x SVN version. All of our main development
>>>>>> goes on there and we build our releases from there. To get Mixxx from 
>>>>>> SVN,
>>>>>> run:
>>>>>> svn co https://mixxx.svn.sourceforge.net/svnroot/mixxx/trunk/mixxx
>>>>>>
>>>>>> Here's some useful wiki pages that should answer some of your other
>>>>>> questions:
>>>>>> http://mixxx.org/wiki/doku.php/coding_guidelines
>>>>>> http://mixxx.org/wiki/doku.php/submitting_patches
>>>>>> http://mixxx.org/wiki/doku.php/development_roadmap
>>>>>> http://mixxx.org/wiki/doku.php/compiling_on_linux
>>>>>>
>>>>>> Lastly, if you send us a few good patches, we have no problems with
>>>>>> giving people SVN access.
>>>>>>
>>>>>> Feel free to ask any other questions you have about development or any
>>>>>> of the library code!
>>>>>>
>>>>>> Thanks,
>>>>>> Albert
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> ---
>>>>> Gaetan - http://www.xeberon.net/gaetan/
>>>>>
>>>>> -------------------------------------------------------------------------
>>>>> This SF.net email is sponsored by: Microsoft
>>>>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>>>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>>>>> _______________________________________________
>>>>> Mixxx-devel mailing list
>>>>> [email protected]
>>>>> https://lists.sourceforge.net/lists/listinfo/mixxx-devel
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> __
>>>> --- == __/ t.O ==--
>>>> http://stacktrace.org/
>>>
>>>
>>>
>>>
>>> --
>>> ---
>>> Gaetan - http://www.xeberon.net/gaetan/
>>>
>>
>>
>>
>> --
>> __
>> --- == __/ t.O ==--
>> http://stacktrace.org/
>>
>
>
>
> --
> ---
> Gaetan - http://www.xeberon.net/gaetan/
>



-- 
---
Gaetan - http://www.xeberon.net/gaetan/
Index: src/soundsourcemp3.cpp
===================================================================
--- src/soundsourcemp3.cpp	(révision 2025)
+++ src/soundsourcemp3.cpp	(copie de travail)
@@ -18,7 +18,34 @@
 #include "soundsourcemp3.h"
 #include <QtDebug>
 
+/** Genre table as defined in ID3v2 spec*/
+const int MAX_ID3_GENRES = 126;
+const char* ID3_GENRE_TABLE [MAX_ID3_GENRES] = {
+    "Blues", "Classic Rock", "Country",
+    "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz",
+    "Metal", "New Age", "Oldies", "Other", "Pop", "R&B",
+    "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative",
+    "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient",
+    "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical",
+    "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel",
+    "Noise", "AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative",
+    "Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic", "Darkwave",
+    "Techno-Industrial", "Electronic", "Pop-Folk", "Eurodance", "Dream",
+    "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap",
+    "Pop/Funk", "Jungle", "Native American", "Cabaret", "New Wave", "Psychadelic",
+    "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz",
+    "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk-Rock",
+    "National Folk", "Swing", "Fast Fusion", "Bebob", "Latin",  "Revival",
+    "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progressive Rock",
+    "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus",
+    "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera",
+    "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", "Porn Groove",
+    "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad",
+    "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", "Punk Rock",
+    "Drum Solo", "A capella", "Euro-House", "Dance Hall" }; 
 
+
+
 SoundSourceMp3::SoundSourceMp3(QString qFilename) : SoundSource(qFilename)
 {
     QFile file( qFilename );
@@ -486,6 +513,20 @@
                 Track->setBpm(bpm);
                 Track->setBpmConfirm(true);
             }
+            s="";
+            getField(tag,"TCON",&s);
+            bool ok = 1;
+            int index = -1;
+            if (index = s.toInt(&ok) && (ok != false))
+            {
+                // genre is an index in ID3_GENRE_TABLE
+                if ((index > 0) && (index < MAX_ID3_GENRES))
+                    Track->setGenre(ID3_GENRE_TABLE[index]);
+            }
+            else
+                if (s.length()>2)
+                    Track->setGenre(s);
+            s="";
             Track->setHeaderParsed(true);
 
             /*
Index: src/soundsourcemp3.h
===================================================================
--- src/soundsourcemp3.h	(révision 2025)
+++ src/soundsourcemp3.h	(copie de travail)
@@ -32,6 +32,7 @@
 #include <id3tag.h>
 #include <q3ptrlist.h>
 
+
 /** Struct used to store mad frames for seeking */
 typedef struct MadSeekFrameType {
     unsigned char *m_pStreamPos;
Index: src/soundsourceoggvorbis.cpp
===================================================================
--- src/soundsourceoggvorbis.cpp	(révision 2025)
+++ src/soundsourceoggvorbis.cpp	(copie de travail)
@@ -182,6 +182,8 @@
         Track->setTitle(vorbis_comment_query(comment, "title", 0));
     if (QString(vorbis_comment_query(comment, "artist", 0)).length()!=0)
         Track->setArtist(vorbis_comment_query(comment, "artist", 0));
+    if (QString(vorbis_comment_query(comment, "genre", 0)).length()!=0)
+        Track->setGenre(vorbis_comment_query(comment, "genre", 0));
     if (QString(vorbis_comment_query(comment, "TBPM", 0)).length()!=0) {
         float bpm = str2bpm(vorbis_comment_query(comment, "TBPM", 0));
         if(bpm > 0) {
Index: src/track.cpp
===================================================================
--- src/track.cpp	(révision 2025)
+++ src/track.cpp	(copie de travail)
@@ -260,13 +260,14 @@
         double centa = m_pView->m_pTrackTableView->size().width()/100.;
         qDebug() << "Adjusting column widths: tracktable width =" << m_pView->m_pTrackTableView->size().width() <<" 1% of that is:"<< centa << " FIXME: this should be done when initalizing the skin.";
         m_pView->m_pTrackTableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+        m_pView->m_pTrackTableView->setColumnWidth(COL_GENRE, 10 * centa);
         m_pView->m_pTrackTableView->setColumnWidth(COL_ARTIST, 15 * centa);
-        m_pView->m_pTrackTableView->setColumnWidth(COL_TITLE, 40 * centa);
-        m_pView->m_pTrackTableView->setColumnWidth(COL_TYPE, (20/4.) * centa);
-        m_pView->m_pTrackTableView->setColumnWidth(COL_LENGTH, (20/4.) * centa);
-        m_pView->m_pTrackTableView->setColumnWidth(COL_BITRATE, (20/4.) * centa);
-        m_pView->m_pTrackTableView->setColumnWidth(COL_BPM, (20/4.) * centa);
-        m_pView->m_pTrackTableView->setColumnWidth(COL_COMMENT, 25 * centa);
+        m_pView->m_pTrackTableView->setColumnWidth(COL_TITLE, 35 * centa);
+        m_pView->m_pTrackTableView->setColumnWidth(COL_TYPE, 5 * centa);
+        m_pView->m_pTrackTableView->setColumnWidth(COL_LENGTH, 5 * centa);
+        m_pView->m_pTrackTableView->setColumnWidth(COL_BITRATE, 5 * centa);
+        m_pView->m_pTrackTableView->setColumnWidth(COL_BPM, 5 * centa);
+        m_pView->m_pTrackTableView->setColumnWidth(COL_COMMENT, 20 * centa);
         if ( (20/4.) * centa <= 42 ) { // If we won't get enough percentage to display length, we have to make some adjustments...
           qDebug() << "Shrinking Title/Comment for small screen... ";
           m_pView->m_pTrackTableView->setColumnWidth(COL_TYPE, 35);
Index: src/trackinfoobject.cpp
===================================================================
--- src/trackinfoobject.cpp	(révision 2025)
+++ src/trackinfoobject.cpp	(copie de travail)
@@ -103,6 +103,7 @@
     m_sFilepath = XmlParse::selectNodeQString(nodeHeader, "Filepath");
     m_sTitle = XmlParse::selectNodeQString(nodeHeader, "Title");
     m_sArtist = XmlParse::selectNodeQString(nodeHeader, "Artist");
+    m_sGenre = XmlParse::selectNodeQString(nodeHeader, "Genre");
     m_sType = XmlParse::selectNodeQString(nodeHeader, "Type");
     m_sComment = XmlParse::selectNodeQString(nodeHeader, "Comment");
     m_iDuration = XmlParse::selectNodeQString(nodeHeader, "Duration").toInt();
@@ -192,6 +193,7 @@
     XmlParse::addElement( doc, header, "Filepath", m_sFilepath );
     XmlParse::addElement( doc, header, "Title", m_sTitle );
     XmlParse::addElement( doc, header, "Artist", m_sArtist );
+    XmlParse::addElement( doc, header, "Genre", m_sGenre );
     XmlParse::addElement( doc, header, "Type", m_sType );
     XmlParse::addElement( doc, header, "Comment", m_sComment);
     XmlParse::addElement( doc, header, "Duration", QString("%1").arg(m_iDuration));
@@ -615,6 +617,25 @@
  */
 }
 
+
+QString TrackInfoObject::getGenre() const
+{
+    m_qMutex.lock();
+    QString sGenre = m_sGenre;
+    m_qMutex.unlock();
+
+    return sGenre;
+}
+
+
+void TrackInfoObject::setGenre(QString s)
+{
+    m_qMutex.lock();
+    m_sGenre = s;
+    m_qMutex.unlock();
+}
+
+
 QString TrackInfoObject::getFilename()  const
 {
     m_qMutex.lock();
Index: src/trackinfoobject.h
===================================================================
--- src/trackinfoobject.h	(révision 2025)
+++ src/trackinfoobject.h	(copie de travail)
@@ -129,6 +129,10 @@
     QString getArtist() const;
     /** Set artist */
     void setArtist(QString);
+    /** Return genre */
+    QString getGenre() const;
+    /** Set genre */
+    void setGenre(QString);
     /** Return filename */
     QString getFilename() const;
     /** Return true if the file exist */
@@ -184,6 +188,8 @@
     QString m_sArtist;
     /** Title */
     QString m_sTitle;
+    /** Genre */
+    QString m_sGenre;
     /** File type */
     QString m_sType;
     /** User comment */
Index: src/wtracktablemodel.cpp
===================================================================
--- src/wtracktablemodel.cpp	(révision 2025)
+++ src/wtracktablemodel.cpp	(copie de travail)
@@ -14,6 +14,7 @@
     m_pTrackPlaylist = NULL;
 
     //setHeaderData(COL_SCORE,Qt::Horizontal, tr("**"));
+    setHeaderData(COL_GENRE,Qt::Horizontal, tr("Genre"));
     setHeaderData(COL_TITLE,Qt::Horizontal, tr("Title"));
     setHeaderData(COL_ARTIST,Qt::Horizontal, tr("Artist"));
     setHeaderData(COL_TYPE,Qt::Horizontal, tr("Type"));
@@ -38,7 +39,7 @@
 
 int WTrackTableModel::columnCount(const QModelIndex &parent) const
 {
-    return 7;
+    return MAX_COLNUMBER;
 }
 
 QVariant WTrackTableModel::data(const QModelIndex &index, int role) const
@@ -56,6 +57,7 @@
         switch(index.column())
         {
         //case COL_SCORE: return m_pTrackInfo->getScoreStr();
+        case COL_GENRE: return m_pTrackInfo->getGenre();
         case COL_TITLE: return m_pTrackInfo->getTitle();
         case COL_ARTIST: return m_pTrackInfo->getArtist();
         case COL_TYPE: return m_pTrackInfo->getType();
@@ -85,6 +87,8 @@
         {
         //case COL_SCORE:
         //    return QString("**");
+        case COL_GENRE:
+            return QString("Genre");
         case COL_TITLE:
             return QString("Title");
         case COL_ARTIST:
Index: src/wtracktablemodel.h
===================================================================
--- src/wtracktablemodel.h	(révision 2025)
+++ src/wtracktablemodel.h	(copie de travail)
@@ -4,14 +4,17 @@
 #include <QAbstractTableModel>
 #include <qcolor.h>
 
+const int MAX_COLNUMBER = 8;
+
 const int COL_SCORE = -1;
-const int COL_ARTIST = 0;
-const int COL_TITLE = 1;
-const int COL_TYPE  = 2;
-const int COL_LENGTH = 3;
-const int COL_BITRATE = 4;
-const int COL_BPM = 5;
-const int COL_COMMENT = 6;
+const int COL_GENRE = 0;
+const int COL_ARTIST = 1;
+const int COL_TITLE = 2;
+const int COL_TYPE  = 3;
+const int COL_LENGTH = 4;
+const int COL_BITRATE = 5;
+const int COL_BPM = 6;
+const int COL_COMMENT = 7;
 
 class TrackPlaylist;
 class TrackCollection;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to