Program Listing for File MusicControlPannel.hpp

Return to documentation for file (include\audioRender\ManualMix\MusicControlPannel.hpp)

#pragma once

#include "Decoder.hpp"

#include <map>

#include "ManualMix.hpp"
#include "PDJE_EXPORT_SETTER.hpp"
#include "SoundTouch.h"
#include "dbRoot.hpp"
#include "fileNameSanitizer.hpp"
#include <filesystem>

namespace fs = std::filesystem;
// #undef HWY_TARGET_INCLUDE
// #define HWY_TARGET_INCLUDE "MusicControlPannel-inl.h"
// #include "hwy/foreach_target.h"
// #include <hwy/highway.h>

using LOADED_LIST = std::vector<std::string>;

struct MusicOnDeck {
    bool                                  play = false;
    Decoder                               dec;
    FXControlPannel                      *fxP;
    std::optional<soundtouch::SoundTouch> st;
    MusicOnDeck() : fxP(new FXControlPannel(48000))
    {
        st.emplace();
        st->setChannels(CHANNEL);
        st->setSampleRate(SAMPLERATE);
        st->setSetting(0, 1);
        st->setSetting(2, 0);
        st->setTempo(1.0);
    };
    ~MusicOnDeck()
    {
        // ma_decoder_uninit(&dec);
        delete fxP;
    }
};

using LOADS = std::map<std::string, MusicOnDeck>;

class PDJE_API MusicControlPannel {
  private:
    LOADS              deck;
    unsigned long      fsize;
    std::vector<float> L;
    std::vector<float> R;
    float             *FaustStyle[2];
    SIMD_FLOAT         tempFrames;

  public:
    bool
    LoadMusic(litedb &ROOTDB, const musdata &Mus);

    bool
    CueMusic(const UNSANITIZED &title, const unsigned long long newPos);

    bool
    SetMusic(const UNSANITIZED &title, const bool onOff);

    LOADED_LIST
    GetLoadedMusicList();

    bool
    UnloadMusic(const UNSANITIZED &title);

    bool
    GetPCMFrames(float *array, const unsigned long FrameSize);

    FXControlPannel *
    getFXHandle(const UNSANITIZED &title);

    bool
    ChangeBpm(const UNSANITIZED &title,
              const double       targetBpm,
              const double       originBpm);

    MusicControlPannel(const unsigned long FrameSize) : fsize(FrameSize)
    {
    }
    ~MusicControlPannel();
};