[easytag] Read the WavPack channel mask



commit 77c2379a132805b57ca3e31f497d9f67be88c51a
Author: David King <amigadave amigadave com>
Date:   Sun Dec 21 22:16:06 2014 +0000

    Read the WavPack channel mask
    
    Use WavpackGetChannelMask() to read the channel mask from the WavPack
    header, and add a new et_wavpack_channel_mask_to_string() function to
    format it for display.

 src/tags/wavpack_header.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/src/tags/wavpack_header.c b/src/tags/wavpack_header.c
index 5af6c6f..ecd48dc 100644
--- a/src/tags/wavpack_header.c
+++ b/src/tags/wavpack_header.c
@@ -58,6 +58,7 @@ et_wavpack_header_read_file_info (GFile *file,
     ETFileInfo->bitrate     = WavpackGetAverageBitrate(wpc, 0)/1000;
     ETFileInfo->samplerate  = WavpackGetSampleRate(wpc);
     ETFileInfo->mode        = WavpackGetNumChannels(wpc);
+    ETFileInfo->layer = WavpackGetChannelMask (wpc);
     ETFileInfo->size        = WavpackGetFileSize(wpc);
     ETFileInfo->duration    = WavpackGetNumSamples(wpc)/ETFileInfo->samplerate;
 
@@ -66,6 +67,35 @@ et_wavpack_header_read_file_info (GFile *file,
     return TRUE;
 }
 
+/*
+ * et_wavpack_channel_mask_to_string:
+ * @channels: total number of channels
+ * @mask: Microsoft channel mask
+ *
+ * Formats a number of channels and a channel mask into a string, suitable for
+ * display to the user.
+ *
+ * Returns: the formatted channel information
+ */
+static gchar *
+et_wavpack_channel_mask_to_string (gint channels,
+                                   gint mask)
+{
+    gboolean lfe;
+
+    /* Low frequency effects channel is bit 3. */
+    lfe = mask & (1 << 3);
+
+    if (lfe)
+    {
+        return g_strdup_printf ("%d.1", channels - 1);
+    }
+    else
+    {
+        return g_strdup_printf ("%d", channels);
+    }
+}
+
 EtFileHeaderFields *
 et_wavpack_header_display_file_info_to_ui (const ET_File *ETFile)
 {
@@ -93,7 +123,8 @@ et_wavpack_header_display_file_info_to_ui (const ET_File *ETFile)
 
     /* Mode */
     fields->mode_label = _("Channels:");
-    fields->mode = g_strdup_printf ("%d", info->mode);
+    fields->mode = et_wavpack_channel_mask_to_string (info->mode,
+                                                      info->layer);
 
     /* Size */
     size = g_format_size (info->size);


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