Changeset 250


Ignore:
Timestamp:
03/28/07 19:19:56 (17 years ago)
Author:
r2d
Message:
  • can now read file tags and display
  • doesn't work with accentuated file names (don't know why, taglib issue ?)
Location:
winamp-musepack/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • winamp-musepack/trunk/mpc_player.cpp

    r249 r250  
    144144                        }
    145145                        WaitForSingleObject(wait_event, 100);           // give a little CPU time back to the system.
    146                 } else if (mod->outMod->CanWrite() >= (MPC_FRAME_LENGTH * sizeof(short) * si.channels)*(mod->dsp_isactive()?2:1)) {
     146                } else if (mod->outMod->CanWrite() >= (int)((MPC_FRAME_LENGTH * sizeof(short) * si.channels)*(mod->dsp_isactive()?2:1))) {
    147147                        // CanWrite() returns the number of bytes you can write, so we check that
    148148                        // to the block size. the reason we multiply the block size by two if
     
    255255        // dividing by 1000 for the first parameter of setinfo makes it
    256256        // display 'H'... for hundred.. i.e. 14H Kbps.
    257         mod->SetInfo(si.average_bitrate / 1000, si.sample_freq / 1000, si.channels, 1);
     257        mod->SetInfo((int)(si.average_bitrate / 1000), si.sample_freq / 1000, si.channels, 1);
    258258
    259259        // initialize visualization stuff
     
    273273}
    274274
    275 //void mpc_player::loadTags(mpc_info ^ infoBox)
    276 //{
    277 //      if(tag_file == 0)
    278 //              tag_file = new TagLib::FileRef(lastfn, false);
    279 //
    280 //      if (!tag_file->isNull() && tag_file->tag()) {
    281 //              TagLib::Tag *tag = tag_file->tag();
    282 //              infoBox->txtTitle->Text = gcnew String(tag->title().toCString(true), 0, strlen(tag->title().toCString(true)), System::Text::Encoding::UTF8);
    283 //              infoBox->txtArtist->Text = gcnew String(tag->artist().toCString(true), 0, strlen(tag->artist().toCString(true)), System::Text::Encoding::UTF8);
    284 //              infoBox->txtAlbum->Text = gcnew String(tag->album().toCString(true), 0, strlen(tag->album().toCString(true)), System::Text::Encoding::UTF8);
    285 //              infoBox->txtYear->Text = "";
    286 //              infoBox->txtYear->Text += tag->year();
    287 //              infoBox->txtTrack->Text = "";
    288 //              infoBox->txtTrack->Text += tag->track();
    289 //              infoBox->comboGenre->Text = gcnew String(tag->genre().toCString(true), 0, strlen(tag->genre().toCString(true)), System::Text::Encoding::UTF8);
    290 //              infoBox->txtComment->Text = gcnew String(tag->comment().toCString(true), 0, strlen(tag->comment().toCString(true)), System::Text::Encoding::UTF8);
    291 //      }
    292 //}
    293 
    294 //void mpc_player::writeTags(mpc_info ^ infoBox)
    295 //{
    296 //      if (!tag_file->isNull() && tag_file->tag()) {
    297 //              TagLib::Tag *tag = tag_file->tag();
    298 //
    299 //              pin_ptr<const wchar_t> wch = PtrToStringChars(infoBox->txtTitle->Text);
    300 //              tag->setTitle(wch);
    301 //
    302 //              wch = PtrToStringChars(infoBox->txtArtist->Text);
    303 //              tag->setArtist(wch);
    304 //
    305 //              wch = PtrToStringChars(infoBox->txtAlbum->Text);
    306 //              tag->setAlbum(wch);
    307 //
    308 //              wch = PtrToStringChars(infoBox->txtYear->Text);
    309 //              TagLib::String year(wch);
    310 //              tag->setYear(year.toInt());
    311 //
    312 //              wch = PtrToStringChars(infoBox->txtTrack->Text);
    313 //              TagLib::String track(wch);
    314 //              tag->setTrack(track.toInt());
    315 //
    316 //              wch = PtrToStringChars(infoBox->comboGenre->Text);
    317 //              tag->setGenre(wch);
    318 //
    319 //              wch = PtrToStringChars(infoBox->txtComment->Text);
    320 //              tag->setComment(wch);
    321 //
    322 //              tag_file->save(); // FIXME : make all crash
    323 //      }
    324 //}
     275void mpc_player::writeTags(HWND hDlg)
     276{
     277        if (!tag_file->isNull() && tag_file->tag()) {
     278                TagLib::Tag *tag = tag_file->tag();
     279
     280                //tag->setTitle(wch);
     281                //tag->setArtist(wch);
     282                //tag->setAlbum(wch);
     283
     284                //TagLib::String year(wch);
     285                //tag->setYear(year.toInt());
     286
     287                //TagLib::String track(wch);
     288                //tag->setTrack(track.toInt());
     289
     290                //tag->setGenre(wch);
     291                //tag->setComment(wch);
     292
     293                tag_file->save(); // FIXME : make all crash
     294        }
     295}
    325296
    326297void mpc_player::initDlg(HWND hDlg)
     
    328299        std::ostringstream tmp;
    329300
    330         tmp << "Streamversion ";
    331         tmp << si.stream_version;
    332         tmp << "\nEncoder : ";
    333         tmp << si.encoder;
    334         tmp << "\nProfile : ";
    335         tmp << si.profile_name;
     301        tmp << "Streamversion " << si.stream_version;
     302        tmp << "\nEncoder : " << si.encoder;
     303        tmp << "\nProfile : " << si.profile_name;
    336304        tmp << "\nPNS : ";
    337305        if (si.pns) tmp << "on";
     
    340308        if (si.is_true_gapless) tmp << "on";
    341309        else tmp << "off";
    342         tmp << "\nAverage bitrate : ";
    343         tmp << floor(si.average_bitrate * 1.e-3 + .5);
    344         tmp << " Kbps \nSamplerate : ";
    345         tmp << si.sample_freq;
    346         tmp << "\nChannels : ";
    347         tmp << si.channels;
    348         tmp << "\nFile size : ";
    349         tmp << si.total_file_length;
    350         tmp << " Bytes";
    351         //// FIXME : add replay gain info
     310        tmp << "\nAverage bitrate : " << floor(si.average_bitrate * 1.e-3 + .5) << " Kbps";
     311        tmp << "\nSamplerate : " << si.sample_freq;
     312        tmp << "\nChannels : " << si.channels;
     313        tmp << "\nFile size : " << si.total_file_length << " Bytes";
     314        //// FIXME : add replay gain info, lenth (min:sec), sample number
    352315
    353316        SetDlgItemText(hDlg, IDC_STREAM_INFO, tmp.str().c_str());
     317
     318        if(tag_file == 0)
     319                tag_file = new TagLib::FileRef(lastfn, false);
     320
     321        if (!tag_file->isNull() && tag_file->tag()) {
     322                TagLib::Tag *tag = tag_file->tag();
     323                SetDlgItemText(hDlg, IDC_TITLE, tag->title().toCString(true));
     324                SetDlgItemText(hDlg, IDC_ARTIST, tag->artist().toCString(true));
     325                SetDlgItemText(hDlg, IDC_ALBUM, tag->album().toCString(true));
     326                tmp.str("");
     327                tmp << tag->year();
     328                SetDlgItemText(hDlg, IDC_YEAR, tmp.str().c_str());
     329                tmp.str("");
     330                tmp << tag->track();
     331                SetDlgItemText(hDlg, IDC_TRACK, tmp.str().c_str());
     332                SetDlgItemText(hDlg, IDC_GENRE, tag->genre().toCString(true));
     333                SetDlgItemText(hDlg, IDC_COMMENT, tag->comment().toCString(true));
     334        }
    354335}
    355336
     
    360341        {
    361342        case WM_INITDIALOG:
     343                SetWindowLong(hDlg, DWL_USER, lParam);
    362344                ((mpc_player *) lParam)->initDlg(hDlg);
    363345                return TRUE;
    364346
    365347        case WM_COMMAND:
    366                 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
    367                 {
     348                if (LOWORD(wParam) == IDC_CANCEL || LOWORD(wParam) == IDCANCEL) {
     349                        EndDialog(hDlg, LOWORD(wParam));
     350                        return TRUE;
     351                } else if (LOWORD(wParam) == IDC_RELOAD) {
     352                        // FIXME : this will not work on X64
     353                        ((mpc_player*)GetWindowLong(hDlg, DWL_USER))->initDlg(hDlg);
     354                } else if (LOWORD(wParam) == IDC_SAVE) {
     355                        ((mpc_player*)GetWindowLong(hDlg, DWL_USER))->writeTags(hDlg);
    368356                        EndDialog(hDlg, LOWORD(wParam));
    369357                        return TRUE;
  • winamp-musepack/trunk/mpc_player.h

    r249 r250  
    3838
    3939        void getFileInfo(char *title, int *length_in_ms);
    40         int getLength(void) {return si.samples * 1000 / si.sample_freq;}
    41         int getOutputTime(void) {return decode_pos_sample * 1000 / si.sample_freq;}
     40        int getLength(void) {return (int)(si.samples * 1000 / si.sample_freq);}
     41        int getOutputTime(void) {return (int)(decode_pos_sample * 1000 / si.sample_freq);}
    4242
    4343        void setOutputTime(int time_in_ms);
     
    4545        int infoDlg(HWND hwnd);
    4646        void initDlg(HWND hDlg);
     47        void writeTags(HWND hDlg);
    4748
    4849        int paused;                             // are we paused?
  • winamp-musepack/trunk/resource.h

    r249 r250  
    66#define IDD_INFO_BOX                    101
    77#define IDC_STREAM_INFO                 1001
     8#define IDC_TITLE                       1002
     9#define IDC_ARTIST                      1003
     10#define IDC_GENRE                       1004
     11#define IDC_ALBUM                       1005
     12#define IDC_BUTTON1                     1006
     13#define IDC_CANCEL                      1006
     14#define IDC_YEAR                        1007
     15#define IDC_RELOAD                      1008
     16#define IDC_SAVE                        1009
     17#define IDC_TRACK                       1010
     18#define IDC_COMMENT                     1011
    819#define IDC_STATIC                      -1
    920
     
    1223#ifdef APSTUDIO_INVOKED
    1324#ifndef APSTUDIO_READONLY_SYMBOLS
    14 #define _APS_NEXT_RESOURCE_VALUE        101
     25#define _APS_NEXT_RESOURCE_VALUE        102
    1526#define _APS_NEXT_COMMAND_VALUE         40001
    16 #define _APS_NEXT_CONTROL_VALUE         1002
     27#define _APS_NEXT_CONTROL_VALUE         1007
    1728#define _APS_NEXT_SYMED_VALUE           101
    1829#endif
  • winamp-musepack/trunk/winamp-musepack.rc

    r249 r250  
    5757//
    5858
    59 IDD_INFO_BOX DIALOGEX 0, 0, 424, 246
     59IDD_INFO_BOX DIALOGEX 0, 0, 406, 186
    6060STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
    6161CAPTION "Musepack file information"
    6262FONT 8, "MS Shell Dlg", 0, 0, 0x0
    6363BEGIN
    64     GROUPBOX        "File stream informations",IDC_STATIC,264,0,156,240,
    65                     BS_FLAT
     64    GROUPBOX        "Stream",IDC_STATIC,264,0,138,180,BS_FLAT
    6665    LTEXT           "C'est juste un test.\nPour voir si tout va bien.",
    67                     IDC_STREAM_INFO,270,11,144,228
     66                    IDC_STREAM_INFO,270,11,126,163
     67    GROUPBOX        "Tag",IDC_STATIC,6,0,252,180,BS_FLAT
     68    EDITTEXT        IDC_TITLE,54,12,198,12,ES_AUTOHSCROLL
     69    RTEXT           "Title",IDC_STATIC,12,14,36,8
     70    EDITTEXT        IDC_ARTIST,54,30,198,12,ES_AUTOHSCROLL
     71    RTEXT           "Artist",IDC_STATIC,12,32,36,8
     72    EDITTEXT        IDC_ALBUM,54,48,198,12,ES_AUTOHSCROLL
     73    RTEXT           "Album",IDC_STATIC,12,50,36,8
     74    EDITTEXT        IDC_YEAR,54,66,42,12,ES_AUTOHSCROLL | ES_NUMBER
     75    RTEXT           "Year",IDC_STATIC,12,68,36,8
     76    EDITTEXT        IDC_TRACK,228,66,24,12,ES_AUTOHSCROLL | ES_NUMBER
     77    RTEXT           "Track",IDC_STATIC,162,68,60,8
     78    COMBOBOX        IDC_GENRE,54,84,198,18,CBS_DROPDOWN | CBS_SORT |
     79                    WS_VSCROLL | WS_TABSTOP
     80    RTEXT           "Genre",IDC_STATIC,12,86,36,8
     81    EDITTEXT        IDC_COMMENT,54,102,198,54,ES_MULTILINE | ES_AUTOHSCROLL
     82    RTEXT           "Comment",IDC_STATIC,12,104,36,8
     83    PUSHBUTTON      "Cancel",IDC_CANCEL,186,162,66,12
     84    PUSHBUTTON      "Reload",IDC_RELOAD,99,162,66,12
     85    PUSHBUTTON      "Save",IDC_SAVE,12,162,66,12
    6886END
    6987
     
    8098    BEGIN
    8199        LEFTMARGIN, 7
    82         RIGHTMARGIN, 417
     100        RIGHTMARGIN, 399
    83101        TOPMARGIN, 7
    84         BOTTOMMARGIN, 239
     102        BOTTOMMARGIN, 179
    85103    END
    86104END
Note: See TracChangeset for help on using the changeset viewer.