~jcowgill/ubuntu/trusty/easytag/bug-1295882

« back to all changes in this revision

Viewing changes to src/wavpack_header.c

  • Committer: Bazaar Package Importer
  • Author(s): Michal Čihař
  • Date: 2008-09-08 21:44:11 UTC
  • mfrom: (3.1.10 hardy)
  • Revision ID: james.westby@ubuntu.com-20080908214411-v237hcgn5d97ecut
Tags: 2.1.4-1.1
* Non-maintainer upload.
* Warn user when ogg vorbis tags will be lost, fix handling of multiple same
  ogg vorbis tags (Closes: #460247).
* Fix lintian warnings:
  - Add watch file.
  - Install icon for menu file (Closes: #477456).
  - Fix section in menu file.
  - Drop version from NAME section of man page to `apropos' and `whatis'
    happy.
  - Include copyright information in debian/copyright.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* wavpack_header.c - 2007/02/15 */
 
2
/*
 
3
 *  EasyTAG - Tag editor for many file types
 
4
 *  Copyright (C) 2007 Maarten Maathuis (madman2003@gmail.com)
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
19
 */
 
20
 
 
21
#include <config.h>
 
22
 
 
23
#ifdef ENABLE_WAVPACK
 
24
 
 
25
#include <gtk/gtk.h>
 
26
#include <glib/gi18n-lib.h>
 
27
#include <stdio.h>
 
28
#include <errno.h>
 
29
#include <string.h>
 
30
#include <wavpack/wavpack.h>
 
31
 
 
32
#include "easytag.h"
 
33
#include "et_core.h"
 
34
#include "misc.h"
 
35
#include "charset.h"
 
36
#include "wavpack_header.h"
 
37
 
 
38
 
 
39
gboolean Wavpack_Header_Read_File_Info(gchar *filename, ET_File_Info *ETFileInfo)
 
40
{
 
41
    WavpackContext *wpc;
 
42
 
 
43
    wpc = WavpackOpenFileInput(filename, NULL, 0, 0);
 
44
 
 
45
    if ( wpc == NULL ) {
 
46
        return FALSE;
 
47
    }
 
48
 
 
49
    ETFileInfo->version     = WavpackGetVersion(wpc);
 
50
    /* .wvc correction file not counted */
 
51
    ETFileInfo->bitrate     = WavpackGetAverageBitrate(wpc, 0)/1000;
 
52
    ETFileInfo->samplerate  = WavpackGetSampleRate(wpc);
 
53
    ETFileInfo->mode        = WavpackGetNumChannels(wpc);
 
54
    ETFileInfo->size        = WavpackGetFileSize(wpc);
 
55
    ETFileInfo->duration    = WavpackGetNumSamples(wpc)/ETFileInfo->samplerate;
 
56
 
 
57
    WavpackCloseFile(wpc);
 
58
 
 
59
    return TRUE;
 
60
}
 
61
 
 
62
 
 
63
gboolean Wavpack_Header_Display_File_Info_To_UI(gchar *filename_utf8, ET_File_Info *ETFileInfo)
 
64
{
 
65
    gchar *text;
 
66
    gchar *time = NULL;
 
67
    gchar *time1 = NULL;
 
68
    gchar *size = NULL;
 
69
    gchar *size1 = NULL;
 
70
 
 
71
    /* Encoder version */
 
72
    gtk_label_set_text(GTK_LABEL(VersionLabel),_("Encoder:"));
 
73
    text = g_strdup_printf("%d",ETFileInfo->version);
 
74
    gtk_label_set_text(GTK_LABEL(VersionValueLabel),text);
 
75
    g_free(text);
 
76
 
 
77
    /* Bitrate */
 
78
    text = g_strdup_printf(_("%d kb/s"),ETFileInfo->bitrate);
 
79
    gtk_label_set_text(GTK_LABEL(BitrateValueLabel),text);
 
80
    g_free(text);
 
81
 
 
82
    /* Samplerate */
 
83
    text = g_strdup_printf(_("%d Hz"),ETFileInfo->samplerate);
 
84
    gtk_label_set_text(GTK_LABEL(SampleRateValueLabel),text);
 
85
    g_free(text);
 
86
 
 
87
    /* Mode */
 
88
    gtk_label_set_text(GTK_LABEL(ModeLabel),_("Channels:"));
 
89
    text = g_strdup_printf("%d",ETFileInfo->mode);
 
90
    gtk_label_set_text(GTK_LABEL(ModeValueLabel),text);
 
91
    g_free(text);
 
92
 
 
93
    /* Size */
 
94
    size  = Convert_Size(ETFileInfo->size);
 
95
    size1 = Convert_Size(ETCore->ETFileDisplayedList_TotalSize);
 
96
    text  = g_strdup_printf("%s (%s)",size,size1);
 
97
    gtk_label_set_text(GTK_LABEL(SizeValueLabel),text);
 
98
    g_free(size);
 
99
    g_free(size1);
 
100
    g_free(text);
 
101
 
 
102
    /* Duration */
 
103
    time  = Convert_Duration(ETFileInfo->duration);
 
104
    time1 = Convert_Duration(ETCore->ETFileDisplayedList_TotalDuration);
 
105
    text  = g_strdup_printf("%s (%s)",time,time1);
 
106
    gtk_label_set_text(GTK_LABEL(DurationValueLabel),text);
 
107
    g_free(time);
 
108
    g_free(time1);
 
109
    g_free(text);
 
110
 
 
111
    return TRUE;
 
112
}
 
113
 
 
114
#endif /* ENABLE_FLAC */