initial Commit
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
data/
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# Compiler settings
|
||||||
|
CXX := g++
|
||||||
|
CXXFLAGS := -std=c++23 -Wall -Wextra -Wpedantic
|
||||||
|
LDFLAGS := $(shell pkg-config --cflags --libs taglib)
|
||||||
|
|
||||||
|
# Source and object files
|
||||||
|
SRCS := main.cpp src/Tag.cpp src/File.cpp
|
||||||
|
OBJS := $(SRCS:.cpp=.o)
|
||||||
|
|
||||||
|
# Target binary
|
||||||
|
TARGET := soundServe
|
||||||
|
|
||||||
|
# Phony targets
|
||||||
|
.PHONY: all clean run
|
||||||
|
|
||||||
|
# Default target
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
# Link object files into final binary
|
||||||
|
$(TARGET): $(OBJS)
|
||||||
|
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
|
||||||
|
|
||||||
|
# Compile .cpp files into .o files
|
||||||
|
%.o: %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
# Clean build artifacts
|
||||||
|
clean:
|
||||||
|
rm -f $(OBJS) $(TARGET)
|
||||||
|
|
||||||
|
# Run the program
|
||||||
|
run: $(TARGET)
|
||||||
|
./$(TARGET)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Metadata.h"
|
||||||
|
#include <filesystem>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#define MUSIC_FOLDER = {"data/"};
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
class File {
|
||||||
|
public:
|
||||||
|
void importFile( std::string fileName );
|
||||||
|
void importFolder( std::string folderPath );
|
||||||
|
std::vector<std::string> filenames_;
|
||||||
|
private:
|
||||||
|
std::string path_;
|
||||||
|
fs::path musicFolder_ MUSIC_FOLDER;
|
||||||
|
std::string fileName_;
|
||||||
|
fs::path fp_ = musicFolder_ / fileName_;
|
||||||
|
};
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <taglib/tag.h>
|
||||||
|
|
||||||
|
struct Metadata {
|
||||||
|
TagLib::String artist;
|
||||||
|
TagLib::String title;
|
||||||
|
TagLib::String album;
|
||||||
|
TagLib::String albumArtist;
|
||||||
|
unsigned int year;
|
||||||
|
std::string artwork;
|
||||||
|
TagLib::String genre;
|
||||||
|
unsigned int trackNr;
|
||||||
|
double length;
|
||||||
|
std::string format;
|
||||||
|
unsigned int sampleRate;
|
||||||
|
unsigned int bitRate;
|
||||||
|
};
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Metadata.h"
|
||||||
|
#include <taglib/tstring.h>
|
||||||
|
#include <taglib/fileref.h>
|
||||||
|
|
||||||
|
|
||||||
|
class Tag {
|
||||||
|
public:
|
||||||
|
void readTag( TagLib::FileName fileName );
|
||||||
|
Metadata getMetadata() const;
|
||||||
|
|
||||||
|
std::string& getFilePath() const;
|
||||||
|
private:
|
||||||
|
Metadata metadata_;
|
||||||
|
std::string filePath_;
|
||||||
|
};
|
||||||
+95864
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,36 @@
|
|||||||
|
#include "include/Tag.h"
|
||||||
|
#include "include/File.h"
|
||||||
|
|
||||||
|
//#include <filesystem>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <taglib/fileref.h>
|
||||||
|
|
||||||
|
//namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
File file;
|
||||||
|
Tag tag;
|
||||||
|
//fs::path folderPath{ "data" };
|
||||||
|
file.importFolder( "/home/fegger/Projects/soundServe/data/" );
|
||||||
|
for ( auto& fp : file.filenames_) {
|
||||||
|
std::cout << fp << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( auto& file : file.filenames_ ) {
|
||||||
|
const char* fp = file.c_str();
|
||||||
|
tag.readTag( fp );
|
||||||
|
Metadata meta = tag.getMetadata();
|
||||||
|
std::cout << "Artist: " << meta.artist
|
||||||
|
<< "\nTitle: " << meta.title
|
||||||
|
<< "\nAlbum: " << meta.album
|
||||||
|
<< "\nTrack: " << meta.trackNr
|
||||||
|
<< "\nYear: " << meta.year
|
||||||
|
<< "\nGenre: " << meta.genre
|
||||||
|
<< "\nSamplerate: " << meta.sampleRate
|
||||||
|
<< "\nBitrate: " << meta.bitRate
|
||||||
|
<< "\nLength: " << meta.length;
|
||||||
|
std::cout << "\n----------------------------------------------------------------------\n";
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,21 @@
|
|||||||
|
#include "../include/File.h"
|
||||||
|
#include "../include/miniaudio.h"
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
void File::importFolder( std::string folderPath ) {
|
||||||
|
|
||||||
|
for ( const auto& audioFile : fs::directory_iterator{ folderPath }) {
|
||||||
|
filenames_.reserve( 20 );
|
||||||
|
filenames_.push_back( audioFile.path() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void File::importFile( std::string fileName ) {
|
||||||
|
fileName_ = fileName;
|
||||||
|
fs::path fp = fp_;
|
||||||
|
|
||||||
|
}
|
||||||
BIN
Binary file not shown.
+26
@@ -0,0 +1,26 @@
|
|||||||
|
#include "../include/Metadata.h"
|
||||||
|
#include "../include/Tag.h"
|
||||||
|
|
||||||
|
#include <taglib/tag.h>
|
||||||
|
#include <taglib/fileref.h>
|
||||||
|
|
||||||
|
void Tag::readTag( TagLib::FileName fileName ){
|
||||||
|
TagLib::FileRef f( fileName );
|
||||||
|
if ( !f.isNull() ) {
|
||||||
|
metadata_.artist = ( f.tag()->artist().isEmpty() ) ? "" : f.tag()->artist();
|
||||||
|
metadata_.title = ( f.tag()->title().isEmpty() ) ? "" : f.tag()->title();
|
||||||
|
metadata_.album = ( f.tag()->album().isEmpty() ) ? "" : f.tag()->album();
|
||||||
|
metadata_.trackNr = f.tag()->track();
|
||||||
|
metadata_.year = f.tag()->year();
|
||||||
|
metadata_.genre = f.tag()->genre();
|
||||||
|
metadata_.sampleRate = f.audioProperties()->sampleRate();
|
||||||
|
metadata_.bitRate = f.audioProperties()->bitrate();
|
||||||
|
metadata_.length = f.audioProperties()->lengthInSeconds();
|
||||||
|
// TODO
|
||||||
|
// file format
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Metadata Tag::getMetadata() const {
|
||||||
|
return metadata_;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user