[banshee] Add support for sample rate and bits per sample (bgo#605223)
- From: Alexander Kojevnikov <alexk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] Add support for sample rate and bits per sample (bgo#605223)
- Date: Tue, 23 Feb 2010 23:27:03 +0000 (UTC)
commit 295bbfdb45d5d51cd8d43c296b4a46511748965d
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date: Wed Feb 24 10:25:24 2010 +1100
Add support for sample rate and bits per sample (bgo#605223)
.../Banshee.Core/Banshee.Collection/TrackInfo.cs | 6 +++++
.../Banshee.Core/Banshee.Streaming/StreamTagger.cs | 2 +
.../DatabaseTrackInfo.cs | 12 ++++++++++
.../Banshee.Database/BansheeDbFormatMigrator.cs | 18 ++++++++++++++-
.../Banshee.Services/Banshee.Query/BansheeQuery.cs | 22 +++++++++++++++++++-
.../DefaultColumnController.cs | 18 ++++++++++++++++
.../Banshee.Gui.TrackEditor/StatisticsPage.cs | 4 +++
.../Banshee.Dap.Ipod/IpodTrackInfo.cs | 3 ++
.../Banshee.Dap.Mtp/MtpTrackInfo.cs | 1 +
9 files changed, 83 insertions(+), 3 deletions(-)
---
diff --git a/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs b/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
index 8c1702c..5d72041 100644
--- a/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
+++ b/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
@@ -303,6 +303,12 @@ namespace Banshee.Collection
public virtual int BitRate { get; set; }
[Exportable]
+ public virtual int SampleRate { get; set; }
+
+ [Exportable]
+ public virtual int BitsPerSample { get; set; }
+
+ [Exportable]
public virtual int PlayCount { get; set; }
[Exportable]
diff --git a/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs b/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs
index d243557..1335575 100644
--- a/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs
+++ b/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs
@@ -154,6 +154,8 @@ namespace Banshee.Streaming
track.MimeType = file.MimeType;
track.Duration = file.Properties.Duration;
track.BitRate = file.Properties.AudioBitrate;
+ track.SampleRate = file.Properties.AudioSampleRate;
+ track.BitsPerSample = file.Properties.BitsPerSample;
FindTrackMediaAttributes (track, file);
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
index b58b6a9..23a71c5 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
@@ -540,6 +540,18 @@ namespace Banshee.Collection.Database
set { base.BitRate = value; }
}
+ [DatabaseColumn]
+ public override int SampleRate {
+ get { return base.SampleRate; }
+ set { base.SampleRate = value; }
+ }
+
+ [DatabaseColumn]
+ public override int BitsPerSample {
+ get { return base.BitsPerSample; }
+ set { base.BitsPerSample = value; }
+ }
+
[DatabaseColumn("Rating")]
protected int rating;
public override int Rating {
diff --git a/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs b/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
index 5f61bef..dd08c8d 100644
--- a/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
+++ b/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
@@ -56,8 +56,8 @@ namespace Banshee.Database
// NOTE: Whenever there is a change in ANY of the database schema,
// this version MUST be incremented and a migration method
// MUST be supplied to match the new version number
- protected const int CURRENT_VERSION = 37;
- protected const int CURRENT_METADATA_VERSION = 6;
+ protected const int CURRENT_VERSION = 38;
+ protected const int CURRENT_METADATA_VERSION = 7;
#region Migration Driver
@@ -840,6 +840,18 @@ namespace Banshee.Database
#endregion
+#region Version 38
+
+ [DatabaseVersion (38)]
+ private bool Migrate_38 ()
+ {
+ Execute ("ALTER TABLE CoreTracks ADD COLUMN SampleRate INTEGER DEFAULT 0");
+ Execute ("ALTER TABLE CoreTracks ADD COLUMN BitsPerSample INTEGER DEFAULT 0");
+ return true;
+ }
+
+#endregion
+
#pragma warning restore 0169
#region Fresh database setup
@@ -898,6 +910,8 @@ namespace Banshee.Database
MimeType TEXT,
FileSize INTEGER,
BitRate INTEGER,
+ SampleRate INTEGER,
+ BitsPerSample INTEGER,
Attributes INTEGER DEFAULT {0},
LastStreamError INTEGER DEFAULT {1},
diff --git a/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs b/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs
index a4c8485..1754568 100644
--- a/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs
+++ b/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs
@@ -169,6 +169,24 @@ namespace Banshee.Query
"bitrate", "kbs", "kps"
);
+ public static QueryField SampleRateField = new QueryField (
+ "samplerate", "SampleRate",
+ // Translators: noun
+ Catalog.GetString ("Sample Rate"), "CoreTracks.SampleRate", typeof(NaturalIntegerQueryValue),
+ // Translators: These are unique search fields. You can use CSV for synonyms. Please, no spaces. Blank ok.
+ Catalog.GetString ("samplerate"), Catalog.GetString ("Hz"),
+ "samplerate", "Hz"
+ );
+
+ public static QueryField BitsPerSampleField = new QueryField (
+ "bitspersample", "BitsPerSample",
+ // Translators: noun
+ Catalog.GetString ("Bits Per Sample"), "CoreTracks.BitsPerSample", typeof(NaturalIntegerQueryValue),
+ // Translators: These are unique search fields. You can use CSV for synonyms. Please, no spaces. Blank ok.
+ Catalog.GetString ("bitspersample"), Catalog.GetString ("bitdepth"), Catalog.GetString ("quantization"),
+ "bitspersample", "bitdepth", "quantization"
+ );
+
public static QueryField TitleField = new QueryField (
"title", "DisplayTrackTitle",
Catalog.GetString ("Name"), "CoreTracks.TitleLowered", true,
@@ -344,7 +362,7 @@ namespace Banshee.Query
ArtistField, AlbumField, AlbumArtistField, TitleField, TrackNumberField, TrackCountField, DiscNumberField, DiscCountField,
YearField, GenreField, ComposerField, ConductorField, GroupingField, CommentField, LicenseUriField, RatingField, PlayCountField,
SkipCountField, FileSizeField, UriField, DurationField, MimeTypeField, LastPlayedField, LastSkippedField,
- BpmField, BitRateField, DateAddedField, PlaylistField, SmartPlaylistField, ScoreField, PlaybackErrorField
+ BpmField, BitRateField, SampleRateField, BitsPerSampleField, DateAddedField, PlaylistField, SmartPlaylistField, ScoreField, PlaybackErrorField
);
// Type Initializer
@@ -448,6 +466,8 @@ namespace Banshee.Query
case "year":
case "bitrate":
+ case "samplerate":
+ case "bitspersample":
case "bpm":
case "trackcount":
case "disccount":
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
index 7fa1cdc..32b8219 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
@@ -91,6 +91,8 @@ namespace Banshee.Collection.Gui
DiscNumberAndCountColumn,
BpmColumn,
BitRateColumn,
+ SampleRateColumn,
+ BitsPerSampleColumn,
ConductorColumn,
GroupingColumn
);
@@ -132,6 +134,12 @@ namespace Banshee.Collection.Gui
ColumnCellPositiveInt br_cell = new ColumnCellPositiveInt (null, true, 3, 4);
br_cell.TextFormat = Catalog.GetString ("{0} kbps");
bitrate_column = Create (BansheeQuery.BitRateField, 0.10, false, br_cell);
+ ColumnCellPositiveInt sr_cell = new ColumnCellPositiveInt (null, true, 5, 6);
+ sr_cell.TextFormat = Catalog.GetString ("{0} Hz");
+ samplerate_column = Create (BansheeQuery.SampleRateField, 0.10, false, sr_cell);
+ ColumnCellPositiveInt bps_cell = new ColumnCellPositiveInt (null, true, 2, 2);
+ bps_cell.TextFormat = Catalog.GetString ("{0} bits");
+ bitspersample_column= Create (BansheeQuery.BitsPerSampleField, 0.10, false, bps_cell);
rating_column = Create (BansheeQuery.RatingField, 0.15, false, new ColumnCellRating (null, true));
score_column = Create (BansheeQuery.ScoreField, 0.15, false, new ColumnCellPositiveInt (null, true, 2, 5));
@@ -301,6 +309,16 @@ namespace Banshee.Collection.Gui
get { return bitrate_column; }
}
+ private SortableColumn samplerate_column;
+ public SortableColumn SampleRateColumn {
+ get { return samplerate_column; }
+ }
+
+ private SortableColumn bitspersample_column;
+ public SortableColumn BitsPerSampleColumn {
+ get { return bitspersample_column; }
+ }
+
private SortableColumn conductor_column;
public SortableColumn ConductorColumn {
get { return conductor_column; }
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
index f5f0e47..1072baf 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
@@ -181,6 +181,10 @@ namespace Banshee.Gui.TrackEditor
AddItem (Catalog.GetString ("Audio Sample Rate:"), String.Format ("{0} Hz",
file.Properties.AudioSampleRate));
AddItem (Catalog.GetString ("Audio Channels:"), file.Properties.AudioChannels);
+ if (file.Properties.BitsPerSample > 0) {
+ AddItem (Catalog.GetString ("Bits Per Sample:"), String.Format ("{0} bits",
+ file.Properties.BitsPerSample));
+ }
if ((file.Properties.MediaTypes & TagLib.MediaTypes.Video) != 0) {
AddItem (Catalog.GetString ("Video Dimensions:"), String.Format ("{0}x{1}",
diff --git a/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs b/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs
index 289e6cc..c8303d6 100644
--- a/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs
+++ b/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodTrackInfo.cs
@@ -69,6 +69,7 @@ namespace Banshee.Dap.Ipod
AlbumTitle = track.AlbumTitle;
ArtistName = track.ArtistName;
BitRate = track.BitRate;
+ SampleRate = track.SampleRate;
Bpm = track.Bpm;
Comment = track.Comment;
Composer = track.Composer;
@@ -119,6 +120,7 @@ namespace Banshee.Dap.Ipod
AlbumTitle = String.IsNullOrEmpty (track.Album) ? null : track.Album;
ArtistName = String.IsNullOrEmpty (track.Artist) ? null : track.Artist;
BitRate = track.BitRate;
+ SampleRate = track.SampleRate;
Bpm = (int)track.BPM;
Comment = track.Comment;
Composer = track.Composer;
@@ -199,6 +201,7 @@ namespace Banshee.Dap.Ipod
track.AlbumArtist = AlbumArtist;
track.BitRate = BitRate;
+ track.SampleRate = SampleRate;
track.BPM = (short)Bpm;
track.Comment = Comment;
track.Composer = Composer;
diff --git a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpTrackInfo.cs b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpTrackInfo.cs
index 8932d0f..935d245 100644
--- a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpTrackInfo.cs
+++ b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpTrackInfo.cs
@@ -67,6 +67,7 @@ namespace Banshee.Dap.Mtp
TrackNumber = file.TrackNumber < 0 ? 0 : (int)file.TrackNumber;
Year = file.Year;
BitRate = (int)file.Bitrate;
+ SampleRate = (int)file.SampleRate;
FileSize = (long)file.FileSize;
MediaAttributes = TrackMediaAttributes.AudioStream;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]