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
make PDJE object
call SearchTrack
call InitPlayer
use player. this is handler.
we use “PDJE” class as an interface.
auto engine = PDJE("path/to/root/Database_path");
auto engine = new PDJE("path/to/root/Database_path");
engine = PDJE("path/to/root/Database_path")
this code Initialize engine and interfaces.
Search Track and Music
-
MUS_VEC PDJE::SearchMusic(const UNSANITIZED &Title, const UNSANITIZED &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:
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 UNSANITIZED &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::FULL_PRE_RENDER, Track_Chosen, Buffer_Size);
if(!engine->player){
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 UNSANITIZED &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.
-
bool MusicControlPannel::LoadMusic(litedb &ROOTDB, 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(*engine->DBROOT, MUSIC_TO_LOAD);
-
bool MusicControlPannel::CueMusic(const UNSANITIZED &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 UNSANITIZED &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:
MusicController->GetLoadedMusicList();
-
bool MusicControlPannel::UnloadMusic(const UNSANITIZED &title)
unload music from deck. used to prevent memory leaks.
- Parameters:
title – the target music title
- Returns:
true
- Returns:
false
MusicController->UnloadMusic("MUSIC_TITLE");
-
FXControlPannel *MusicControlPannel::getFXHandle(const UNSANITIZED &title)
gets FX handler
- Parameters:
title – the title of the music
- Returns:
FXControlPannel*, the handler pointer
auto fxHandler = MusicController->getFXHandle("MUSIC_TITLE");
Handle Editor
-
bool PDJE::InitEditor(const DONT_SANITIZE &auth_name, const DONT_SANITIZE &auth_email, const fs::path &projectRoot)
engine->InitEditor("editor's name", "editor's email. no need to fill", "Editor Sandbox Directory");
-
bool editorObject::Open(const fs::path &projectPath)
engine->editor->Open("Editor Sandbox Directory");
This code opens the editor project. if the path is empty, generates new one.
this will be called from PDJE::InitEditor. no need to call twice.
-
DONT_SANITIZE editorObject::DESTROY_PROJECT()
WARNING!!! THERE IS NO TURNING BACK.
engine->editor->DESTROY_PROJECT();
This removes the opened project. use careful.
template<typename EDIT_ARG_TYPE> AddLine<EDIT_ARG_TYPE>(const EDIT_ARG_TYPE& obj)
and
AddLine(const std::string& musicName, const std::string& firstBar)
engine->editor->AddLine<EDIT_ARG_NOTE>(noteObj);
engine->editor->AddLine<EDIT_ARG_KEY_VALUE>(key_value_Obj);
engine->editor->AddLine<EDIT_ARG_MIX>(mixObj);
engine->editor->AddLine<EDIT_ARG_MUSIC>(musicObj);
engine->editor->AddLine("music name", "48000");
this code adds data into the editor project. every add command calls save function, and will be recorded by git.
to see what is that datas, go to pdje format page