HOW TO USE

Initialize PDJE Engine

class PDJE

the main Interface of this Engine PDJE gets music data and track data from database. from that datas, you can activate music player and you can get a music player handler. with this player handler, you can control music’s mixing in real time.

to-use

  1. make PDJE object

  2. call SearchTrack

  3. call InitPlayer

  4. use player. this is handler.

digraph PDJE_Interface_Tree{ PDJE -> Search_Tools; PDJE -> Player; Player -> Player_ON_OFF; Player -> FXController; Player -> MusicController; FXController -> FX_ON_OFF; FXController -> FX_arg_setter; FX_arg_setter -> change_FX_value; MusicController -> Load_Music; MusicController -> Unload_Music; MusicController -> ON_OFF_Music; MusicController -> Cue_Music; MusicController -> FXController; }

we use “PDJE” class as an interface.

PDJE engine = new PDJE("path/to/root/sqlite/database.sql");

this code Initialize engine and interfaces.

Search Track and Music

MUS_VEC PDJE::SearchMusic(const std::string &Title, const std::string &composer, const double bpm = -1)

searches musics and metadatas from database. if you don’t need to filter, send “” to the values

Parameters:
  • Title – the title of the music

  • composer – the composer of the music

  • bpm – the bpm of the music. send under zero to skip filter

Returns:

MUS_VEC

double bpm = 140.0;
auto music_searched = engine->SearchMusic("Music Title", "Composer name", bpm);
if(music_searched.empty()){
    std::cout << "can't find anything" << std::endl;
    return -1;
}
for(auto i : music_searched){
    std::cout
    << "title: "
    << i.title
    << "path: "
    << i.musicPath
    << std::endl;
}
TRACK_VEC PDJE::SearchTrack(const std::string &Title)

searches track the track contains the note data, mix data and included music lists.

Parameters:

Title – the tile of the track. send “” to skip filter

Returns:

TRACK_VEC the array of the track_data. find what you want

auto trackSearch = engine->SearchTrack("Track Title");
if(trackSearch.empty()){
    std::cout << "can't find anything" << std::endl;
    return -1;
}
for(auto i: trackSearch){
    std::cout
    << " track title: "
    << i.trackTitle
    << " note binary size: "
    << i.noteBinary.size()
    << " mix binary size: "
    << i.mixBinary.size()
    << std::endl;
}

Initialize Player

bool PDJE::InitPlayer(PLAY_MODE mode, trackdata &td, const unsigned int FrameBufferSize)

this inits the music handler. the music handler called a “player” it initializes the player

Parameters:
  • mode – the play modes. you can choose “FULL_PRE_RENDER”, “HYBRID_RENDER”, “FULL_MANUAL_RENDER”

  • td – the track data. you can get this from SearchTrack()

  • FrameBufferSize – the buffersize. in this project, it uses 48000 samplerate. if you use 48 as a value, in theory, it calls mixing function 1000 times per second.

Returns:

true no error

Returns:

false error

auto Track_Chosen = trackSearch[0];
int Buffer_Size = 48;
engine->InitPlayer(PLAY_MODE::RENDER_MODE, Track_Chosen, Buffer_Size);
if(!engine->player.has_value()){
    std::cout << "can't use track" << std::endl;
    return -1;
}

Handle Player

class audioPlayer

The music handler class this is the music handler class. you can play/stop music, controlling fx, attach other music in realtime manually or getting music’s playing position and consumed frames.

this is the handler of musics.

bool audioPlayer::Activate()

Plays music.

engine->player->Activate();
bool audioPlayer::Deactivate()

Stops music.

engine->player->Deactivate();
FXControlPannel *audioPlayer::GetFXControlPannel(const std::string &title = "__PDJE__MAIN__")

fx controller getter this returns the fx controller. with this, you can control the fx in realtime manually.

Parameters:

title – the music to control. “__PDJE__MAIN__” means the prerendered music.

Returns:

FXControlPannel* but the “title” doesn’t exists, it returns nullptr.

auto FXController = engine->player->GetFXControlPannel();
MusicControlPannel *audioPlayer::GetMusicControlPannel()

music controller getter this returns the music controller. with this, you can load music, stop music in realtime manually.

Returns:

MusicControlPannel* if something wrong, it returns nullptr.

auto MusicController = engine->player->GetMusicControlPannel();

Handle FXControlPannel

void FXControlPannel::FX_ON_OFF(FXList fx, bool onoff)

activate/deactivate FX

Parameters:
  • fx – the fx type

  • onoff – activate / deactivate

bool TurnON = true;
FXController->FX_ON_OFF(FXList::ChooseFX, TurnON);
ARGSETTER FXControlPannel::GetArgSetter(FXList fx)

Get the Arg Setter object.

Parameters:

fx – the fx type

Returns:

ARGSETTER the FX arg handler

auto argHandler = FXController->GetArgSetter(FXList::ChooseFX);
for(auto i : argHandler){
    std::cout
    << "FX key: "
    << i.first
    << std::endl;
}
double FXValue = 2.0;
argHandler["FX key name"](FXValue);ß
bool FXControlPannel::checkSomethingOn()

check any FX is activated

Returns:

true , something is activated

Returns:

false , nothing activated.

if(FXController->checkSomethingOn()){
    std::cout<< "FX is turned on" << std::endl;
}

Handle MusicControlPannel

class MusicControlPannel

Music handler for manual mode.

int MusicControlPannel::LoadMusic(const musdata &Mus)

loads music to the deck. doesn’t play music

Parameters:

Mus – Searched music

Returns:

int, miniaudio Error code.

auto MUSIC_TO_LOAD = music_searched[0];
MusicController->LoadMusic(MUSIC_TO_LOAD);
bool MusicControlPannel::CueMusic(const TITLE &title, const unsigned long long newPos)

Change playback position of the music.

Parameters:
  • title – the music title

  • newPos – the new playback position of the music

Returns:

true

Returns:

false

unsigned long long music_position = 0;
MusicController->CueMusic("MUSIC_TITLE", music_position);
bool MusicControlPannel::SetMusic(const TITLE &title, const bool onOff)

turn on, off the music

Parameters:
  • title – the music title

  • onOff – True is on, False is off

Returns:

true

Returns:

false

bool ON = true;
MusicController->SetMusic("MUSIC_TITLE", ON);
LOADED_LIST MusicControlPannel::GetLoadedMusicList()

get music list on the deck

Returns:

LOADED_LIST

MusicController->GetLoadedMusicList();
bool MusicControlPannel::UnloadMusic(const TITLE &title)

unload music from deck. used to prevent memory leaks.

Parameters:

title – the target music title

Returns:

true

Returns:

false

MusicControlPannel->UnloadMusic("MUSIC_TITLE");
FXControlPannel *MusicControlPannel::getFXHandle(const TITLE &title)

gets FX handler

Parameters:

title – the title of the music

Returns:

FXControlPannel*, the handler pointer

auto fxHandler = MusicControlPannel->getFXHandle("MUSIC_TITLE");