/** * File metadata was set with Media Monkey 3 * * <p>Checking our fields match the fields used by media Monkey 3 (Defacto Standard) by ensuring * we can read fields written in Media Monkey */ public void testReadFileFromMediaMonkey3() { Exception exceptionCaught = null; try { File testFile = AbstractTestCase.copyAudioToTmp("test1.wma"); AudioFile f = AudioFileIO.read(testFile); assertEquals("32", f.getAudioHeader().getBitRate()); assertEquals( "ASF (audio): 0x0161 (Windows Media Audio (ver 7,8,9))", f.getAudioHeader().getEncodingType()); assertEquals("2", f.getAudioHeader().getChannels()); assertEquals("32000", f.getAudioHeader().getSampleRate()); assertFalse(f.getAudioHeader().isVariableBitRate()); assertTrue(f.getTag() instanceof AsfTag); AsfTag tag = (AsfTag) f.getTag(); System.out.println(tag); // Ease of use methods for common fields assertEquals("artist", tag.getFirst(FieldKey.ARTIST)); assertEquals("album", tag.getFirst(FieldKey.ALBUM)); assertEquals("tracktitle", tag.getFirst(FieldKey.TITLE)); assertEquals("comments", tag.getFirst(FieldKey.COMMENT)); assertEquals("1971", tag.getFirst(FieldKey.YEAR)); assertEquals("3", tag.getFirst(FieldKey.TRACK)); assertEquals("genre", tag.getFirst(FieldKey.GENRE)); assertEquals("artist", tag.getFirst(FieldKey.ARTIST)); assertEquals("artist", tag.getFirst(AsfFieldKey.AUTHOR.getFieldName())); assertEquals("album", tag.getFirst(FieldKey.ALBUM)); assertEquals("album", tag.getFirst(AsfFieldKey.ALBUM.getFieldName())); assertEquals("tracktitle", tag.getFirst(FieldKey.TITLE)); assertEquals("tracktitle", tag.getFirst(AsfFieldKey.TITLE.getFieldName())); assertEquals("genre", tag.getFirst(FieldKey.GENRE)); assertEquals("genre", tag.getFirst(AsfFieldKey.GENRE.getFieldName())); assertEquals("3", tag.getFirst(FieldKey.TRACK)); assertEquals("1971", tag.getFirst(FieldKey.YEAR)); assertEquals("genre", tag.getFirst(FieldKey.GENRE)); assertEquals("comments", tag.getFirst(FieldKey.COMMENT)); assertEquals("albumartist", tag.getFirst(FieldKey.ALBUM_ARTIST)); assertEquals("composer", tag.getFirst(FieldKey.COMPOSER)); assertEquals("grouping", tag.getFirst(FieldKey.GROUPING)); assertEquals("2", tag.getFirst(FieldKey.DISC_NO)); assertEquals("lyrics for song", tag.getFirst(FieldKey.LYRICS)); assertEquals("encoder", tag.getFirst(FieldKey.ENCODER)); assertEquals("isrc", tag.getFirst(FieldKey.ISRC)); assertEquals("publisher", tag.getFirst(FieldKey.RECORD_LABEL)); assertEquals("Lyricist", tag.getFirst(FieldKey.LYRICIST)); assertEquals("conductor", tag.getFirst(FieldKey.CONDUCTOR)); assertEquals("Mellow", tag.getFirst(FieldKey.MOOD)); // Media Monkey does not currently support these fields ... // assertEquals("is_compilation", tag.getFirst(FieldKey.IS_COMPILATION)); // assertEquals("artist_sort", tag.getFirst(FieldKey.ARTIST_SORT)); // assertEquals("album_artist_sort", tag.getFirst(FieldKey.ALBUM_ARTIST_SORT)); // assertEquals("album_sort", tag.getFirst(FieldKey.ALBUM_SORT)); // assertEquals("title_sort", tag.getFirst(FieldKey.TITLE_SORT)); // assertEquals("barcode", tag.getFirst(FieldKey.BARCODE)); // assertEquals("catalogno", tag.getFirst(FieldKey.CATALOG_NO)); // assertEquals("media", tag.getFirst(FieldKey.MEDIA)); // assertEquals("remixer", tag.getFirst(FieldKey.REMIXER)); // Now } catch (Exception e) { e.printStackTrace(); exceptionCaught = e; } assertNull(exceptionCaught); }
/** * File metadata was set with PicardQt * * <p>Checking our fields match the fields used by picard Qt3 (Defacto Standard for Musicbrainz * fields) by ensuring we can read fields written in Picard Qt */ public void testReadFileFromPicardQt() { File orig = new File("testdata", "test2.wma"); if (!orig.isFile()) { System.err.println("Unable to test file - not available"); return; } Exception exceptionCaught = null; try { File testFile = AbstractTestCase.copyAudioToTmp("test2.wma"); AudioFile f = AudioFileIO.read(testFile); assertEquals("128", f.getAudioHeader().getBitRate()); assertEquals( "ASF (audio): 0x0162 (Windows Media Audio 9 series (Professional))", f.getAudioHeader().getEncodingType()); assertEquals("2", f.getAudioHeader().getChannels()); assertEquals("44100", f.getAudioHeader().getSampleRate()); assertFalse(f.getAudioHeader().isVariableBitRate()); assertTrue(f.getTag() instanceof AsfTag); AsfTag tag = (AsfTag) f.getTag(); System.out.println(tag); // Ease of use methods for common fields assertEquals("Sonic Youth", tag.getFirst(FieldKey.ARTIST)); assertEquals("Sister", tag.getFirst(FieldKey.ALBUM)); assertEquals("(I Got a) Catholic Block", tag.getFirst(FieldKey.TITLE)); assertEquals("1987", tag.getFirst(FieldKey.YEAR)); assertEquals("2", tag.getFirst(FieldKey.TRACK)); // NOTE:track can have seroes or not assertEquals("no wave", tag.getFirst(FieldKey.GENRE)); assertEquals("Sonic Youth", tag.getFirst(FieldKey.ARTIST)); assertEquals("Sonic Youth", tag.getFirst(AsfFieldKey.AUTHOR.getFieldName())); assertEquals("Sister", tag.getFirst(FieldKey.ALBUM)); assertEquals("Sister", tag.getFirst(AsfFieldKey.ALBUM.getFieldName())); assertEquals("(I Got a) Catholic Block", tag.getFirst(FieldKey.TITLE)); assertEquals("(I Got a) Catholic Block", tag.getFirst(AsfFieldKey.TITLE.getFieldName())); assertEquals("no wave", tag.getFirst(FieldKey.GENRE)); assertEquals("no wave", tag.getFirst(AsfFieldKey.GENRE.getFieldName())); assertEquals("2", tag.getFirst(FieldKey.TRACK)); assertEquals("2", tag.getFirst(AsfFieldKey.TRACK.getFieldName())); assertEquals("1987", tag.getFirst(FieldKey.YEAR)); assertEquals("1987", tag.getFirst(AsfFieldKey.YEAR.getFieldName())); assertEquals("Sonic Youth", tag.getFirst(FieldKey.ALBUM_ARTIST)); assertEquals("Sonic Youth", tag.getFirst(AsfFieldKey.ALBUM_ARTIST.getFieldName())); assertEquals("Blast First", tag.getFirst(FieldKey.RECORD_LABEL)); assertEquals("Blast First", tag.getFirst(AsfFieldKey.RECORD_LABEL.getFieldName())); assertEquals("Sonic Youth", tag.getFirst(FieldKey.ARTIST_SORT)); assertEquals("Sonic Youth", tag.getFirst(AsfFieldKey.ARTIST_SORT.getFieldName())); assertEquals("Sonic Youth", tag.getFirst(FieldKey.ARTIST_SORT)); assertEquals("Sonic Youth", tag.getFirst(AsfFieldKey.ARTIST_SORT.getFieldName())); assertEquals("Sonic Youth", tag.getFirst(FieldKey.ALBUM_ARTIST_SORT)); assertEquals("Sonic Youth", tag.getFirst(AsfFieldKey.ALBUM_ARTIST_SORT.getFieldName())); assertEquals("official", tag.getFirst(FieldKey.MUSICBRAINZ_RELEASE_STATUS)); assertEquals("official", tag.getFirst(AsfFieldKey.MUSICBRAINZ_RELEASE_STATUS.getFieldName())); assertEquals("album", tag.getFirst(FieldKey.MUSICBRAINZ_RELEASE_TYPE)); assertEquals("album", tag.getFirst(AsfFieldKey.MUSICBRAINZ_RELEASE_TYPE.getFieldName())); assertEquals("GB", tag.getFirst(FieldKey.MUSICBRAINZ_RELEASE_COUNTRY)); assertEquals("GB", tag.getFirst(AsfFieldKey.MUSICBRAINZ_RELEASE_COUNTRY.getFieldName())); assertEquals( "5cbef01b-cc35-4f52-af7b-d0df0c4f61b9", tag.getFirst(FieldKey.MUSICBRAINZ_RELEASEARTISTID)); assertEquals( "5cbef01b-cc35-4f52-af7b-d0df0c4f61b9", tag.getFirst(AsfFieldKey.MUSICBRAINZ_RELEASEARTISTID.getFieldName())); assertEquals( "f8ece8ad-0ef1-45c0-9d20-a58a10052d5c", tag.getFirst(FieldKey.MUSICBRAINZ_TRACK_ID)); assertEquals( "f8ece8ad-0ef1-45c0-9d20-a58a10052d5c", tag.getFirst(AsfFieldKey.MUSICBRAINZ_TRACK_ID.getFieldName())); assertEquals( "ca16e36d-fa43-4b49-8c71-d98bd70b341f", tag.getFirst(FieldKey.MUSICBRAINZ_RELEASEID)); assertEquals( "ca16e36d-fa43-4b49-8c71-d98bd70b341f", tag.getFirst(AsfFieldKey.MUSICBRAINZ_RELEASEID.getFieldName())); assertEquals( "5cbef01b-cc35-4f52-af7b-d0df0c4f61b9", tag.getFirst(FieldKey.MUSICBRAINZ_ARTISTID)); assertEquals( "5cbef01b-cc35-4f52-af7b-d0df0c4f61b9", tag.getFirst(AsfFieldKey.MUSICBRAINZ_ARTISTID.getFieldName())); // This example doesnt populate these fields // assertEquals("Sonic Youth", tag.getFirst(FieldKey.COMPOSER)); // assertEquals("grouping", tag.getFirst(FieldKey.GROUPING)); // assertEquals("2", tag.getFirst(FieldKey.DISC_NO)); // assertEquals("lyrics for song", tag.getFirst(FieldKey.LYRICS)); // assertEquals("encoder", tag.getFirst(FieldKey.ENCODER)); // assertEquals("isrc", tag.getFirst(FieldKey.ISRC)); // assertEquals("Lyricist", tag.getFirst(FieldKey.LYRICIST)); // assertEquals("conductor", tag.getFirst(FieldKey.CONDUCTOR)); // assertEquals("Mellow", tag.getFirst(FieldKey.INVOLVED_PEOPLE)); // assertEquals("5cbef01b-cc35-4f52-af7b-d0df0c4f61b9", tag.getFirst(FieldKey.MUSICIP_ID)); // Picard Qt does not currently support these fields ... // assertEquals("is_compilation", tag.getFirst(FieldKey.IS_COMPILATION)); // assertEquals("album_sort", tag.getFirst(FieldKey.ALBUM_SORT)); // assertEquals("title_sort", tag.getFirst(FieldKey.TITLE_SORT)); // assertEquals("barcode", tag.getFirst(FieldKey.BARCODE)); // assertEquals("catalogno", tag.getFirst(FieldKey.CATALOG_NO)); // assertEquals("media", tag.getFirst(FieldKey.MEDIA)); // assertEquals("remixer", tag.getFirst(FieldKey.REMIXER)); // Now } catch (Exception e) { e.printStackTrace(); exceptionCaught = e; } assertNull(exceptionCaught); }