summaryrefslogtreecommitdiff
path: root/ext/sndfile
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2013-12-30 15:49:57 +0100
committerStefan Sauer <ensonic@users.sf.net>2013-12-30 15:54:29 +0100
commit3149dbb44bf6d1324ab7affddcd8d716e33d84e0 (patch)
treeb205a6960d9fb904936485b5afc6eeb84d56db43 /ext/sndfile
parent46cb19404df451bf420403de0dc0c900ae5f5e82 (diff)
downloadgstreamer-plugins-bad-3149dbb44bf6d1324ab7affddcd8d716e33d84e0.tar.gz
sndfile: emit midi-base-note tag
Query instrument data. Use both 'loop_info' and 'instrument' to inform about the basenote.
Diffstat (limited to 'ext/sndfile')
-rw-r--r--ext/sndfile/gstsfdec.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/ext/sndfile/gstsfdec.c b/ext/sndfile/gstsfdec.c
index 8271989f1..5467623d8 100644
--- a/ext/sndfile/gstsfdec.c
+++ b/ext/sndfile/gstsfdec.c
@@ -480,6 +480,7 @@ gst_sf_dec_open_file (GstSFDec * self)
{
SF_INFO info = { 0, };
SF_LOOP_INFO loop_info = { 0, };
+ SF_INSTRUMENT instrument = { 0, };
GstCaps *caps;
GstStructure *s;
GstSegment seg;
@@ -489,6 +490,8 @@ gst_sf_dec_open_file (GstSFDec * self)
const gchar *tag;
const gchar *codec_name;
gchar *stream_id;
+ gboolean have_loop_info = FALSE;
+ gboolean have_instrument = FALSE;
GST_DEBUG_OBJECT (self, "opening the stream");
if (!(self->file = sf_open_virtual (&gst_sf_vio, SFM_READ, &info, self)))
@@ -552,6 +555,12 @@ gst_sf_dec_open_file (GstSFDec * self)
if (sf_command (self->file, SFC_GET_LOOP_INFO, &loop_info,
sizeof (loop_info))) {
GST_DEBUG_OBJECT (self, "have loop info");
+ have_loop_info = TRUE;
+ }
+ if (sf_command (self->file, SFC_GET_INSTRUMENT, &instrument,
+ sizeof (instrument))) {
+ GST_DEBUG_OBJECT (self, "have instrument");
+ have_instrument = TRUE;
}
/* send tags */
@@ -583,12 +592,22 @@ gst_sf_dec_open_file (GstSFDec * self)
}
if ((tag = sf_get_string (self->file, SF_STR_TRACKNUMBER))) {
guint track = atoi (tag);
- gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_TRACK_NUMBER, track,
+ gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_TRACK_NUMBER, track,
NULL);
}
- if (loop_info.bpm != 0.0) {
- gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_BEATS_PER_MINUTE,
- (gdouble) loop_info.bpm, NULL);
+ if (have_loop_info) {
+ if (loop_info.bpm != 0.0) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_BEATS_PER_MINUTE,
+ (gdouble) loop_info.bpm, NULL);
+ }
+ if (loop_info.root_key != -1) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_MIDI_BASE_NOTE,
+ (guint) loop_info.root_key, NULL);
+ }
+ }
+ if (have_instrument) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_MIDI_BASE_NOTE,
+ (guint) instrument.basenote, NULL);
}
/* TODO: SF_STR_DATE: GST_TAG_DATE / GST_TAG_DATE_TIME */
/* TODO: calculate bitrate: GST_TAG_BITRATE */