forked from robinst/taglib-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add c++ code to create/update tags in a WAV file
also add c++ code to dump tags from a WAV file remove ruby code to create tags in a WAV file
- Loading branch information
Thomas Chevereau
committed
Jul 30, 2014
1 parent
8dce8fe
commit 2dff3e3
Showing
6 changed files
with
141 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <taglib/taglib.h> | ||
#include <taglib/wavfile.h> | ||
#include <taglib/wavproperties.h> | ||
#include <taglib/attachedpictureframe.h> | ||
|
||
#include "get_picture_data.cpp" | ||
|
||
using namespace TagLib; | ||
|
||
|
||
int main(int argc, char **argv) { | ||
if (argc != 2) { | ||
std::cout << "usage: " << argv[0] << " file.wav" << std::endl; | ||
exit(1); | ||
} | ||
char *filename = argv[1]; | ||
|
||
RIFF::WAV::File file(filename); | ||
ID3v2::Tag *tag = file.tag(); | ||
|
||
tag->setArtist("WAV Dummy Artist Name"); | ||
tag->setAlbum("WAV Dummy Album Title"); | ||
tag->setTitle("WAV Dummy Track Title"); | ||
tag->setTrack(5); | ||
tag->setYear(2014); | ||
tag->setGenre("Jazz"); | ||
tag->setComment("WAV Dummy Comment"); | ||
|
||
tag->removeFrames("APIC"); | ||
|
||
ByteVector picture_data; | ||
ID3v2::AttachedPictureFrame *apic; | ||
|
||
picture_data = getPictureData("globe_east_540.jpg"); | ||
apic = new ID3v2::AttachedPictureFrame(); | ||
apic->setPicture(picture_data); | ||
apic->setMimeType("image/jpeg"); | ||
apic->setType(ID3v2::AttachedPictureFrame::FrontCover); | ||
apic->setDescription("WAV Dummy Front Cover-Art"); | ||
apic->setTextEncoding(String::UTF8); | ||
tag->addFrame(apic); | ||
|
||
picture_data = getPictureData("globe_east_90.jpg"); | ||
apic = new ID3v2::AttachedPictureFrame(); | ||
apic->setPicture(picture_data); | ||
apic->setMimeType("image/jpeg"); | ||
apic->setType(ID3v2::AttachedPictureFrame::Other); | ||
apic->setDescription("WAV Dummy Thumbnail"); | ||
apic->setTextEncoding(String::UTF8); | ||
tag->addFrame(apic); | ||
|
||
file.save(); | ||
} | ||
|
||
// vim: set filetype=cpp sw=2 ts=2 expandtab: |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <taglib/taglib.h> | ||
#include <taglib/wavfile.h> | ||
#include <taglib/wavproperties.h> | ||
#include <taglib/attachedpictureframe.h> | ||
|
||
using namespace TagLib; | ||
|
||
|
||
void dump_id3v2(ID3v2::Tag *tag) | ||
{ | ||
if (!tag || tag->isEmpty()) | ||
{ | ||
std::cout << " NO TAGS" << std::endl; | ||
return; | ||
} | ||
|
||
std::cout << " ID3v2." << tag->header()->majorVersion() << "." << tag->header()->revisionNumber() << std::endl; | ||
std::cout << " title: '" << tag->title() << "'" << std::endl; | ||
std::cout << " artist: '" << tag->artist() << "'" << std::endl; | ||
std::cout << " album: '" << tag->album() << "'" << std::endl; | ||
std::cout << " track: " << tag->track() << std::endl; | ||
std::cout << " year: " << tag->year() << std::endl; | ||
std::cout << " genre: '" << tag->genre() << "'" << std::endl; | ||
std::cout << " comment: '" << tag->comment() << "'" << std::endl; | ||
|
||
std::cout << " Frames" << std::endl; | ||
const ID3v2::FrameList frameList = tag->frameList(); | ||
for(ID3v2::FrameList::ConstIterator it = frameList.begin(); it != frameList.end(); ++it) | ||
std::cout << " " << (*it)->frameID() << " - " << (*it)->toString() << std::endl; | ||
|
||
const ID3v2::FrameList apicList = tag->frameList("APIC"); | ||
for(ID3v2::FrameList::ConstIterator it = apicList.begin(); it != apicList.end(); ++it) | ||
{ | ||
const ID3v2::AttachedPictureFrame *apic = static_cast<ID3v2::AttachedPictureFrame *>(*it); | ||
std::cout << " Picture" << std::endl; | ||
std::cout << " type: " << apic->type() << std::endl; | ||
std::cout << " mime_type: '" << apic->mimeType() << "'" << std::endl; | ||
std::cout << " description: '" << apic->description() << "'" << std::endl; | ||
std::cout << " size: " << apic->picture().size() << " bytes" << std::endl; | ||
} | ||
} | ||
|
||
void dump_audio_properties(AudioProperties *properties) | ||
{ | ||
std::cout << " Audio Properties" << std::endl; | ||
std::cout << " length: " << properties->length() << " (seconds)" << std::endl; | ||
std::cout << " bitrate: " << properties->bitrate() << " (kbits/sec)" << std::endl; | ||
std::cout << " sample_rate: " << properties->sampleRate() << " (Hz)" << std::endl; | ||
std::cout << " channels: " << properties->channels() << std::endl; | ||
} | ||
|
||
void dump_wav_properties(RIFF::WAV::Properties *properties) | ||
{ | ||
std::cout << " WAV-specific Properties" << std::endl; | ||
std::cout << " sample_width: " << properties->sampleWidth() << " (bits)" << std::endl; | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
if (argc != 2) { | ||
std::cout << "usage: " << argv[0] << " file.wav" << std::endl; | ||
exit(1); | ||
} | ||
char *filename = argv[1]; | ||
|
||
std::cout << "WAV file '" << filename << "'..." << std::endl; | ||
|
||
RIFF::WAV::File file(filename); | ||
|
||
dump_id3v2(file.tag()); | ||
dump_audio_properties(file.audioProperties()); | ||
dump_wav_properties(file.audioProperties()); | ||
} | ||
|
||
// vim: set filetype=cpp sw=2 ts=2 expandtab: |