Initial Cross Platform Work

This commit is contained in:
2025-04-24 16:39:24 +02:00
parent dbffb7f316
commit 13c2869ba8
170 changed files with 18611 additions and 10292 deletions

View File

@ -1,54 +1,54 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/core/common.hpp>
namespace PD {
namespace Music {
/**
* Decoder Template class
*/
class Decoder : public SmartCtor<Decoder> {
public:
Decoder() = default;
virtual ~Decoder() = default;
/** Template Init function */
virtual int Init(const std::string& path) = 0;
/** Template deinit function */
virtual void Deinit() = 0;
/** Template function to get sample rate */
virtual u32 GetSampleRate() = 0;
/** template function to get number of channels */
virtual u8 GetChannels() = 0;
/** template function to get buffer size */
virtual size_t GetBufSize() = 0;
/** template decode function */
virtual u64 Decode(u16* buf_address) = 0;
/** template function to get file sanples if exist */
virtual size_t GetFileSamples() = 0;
};
} // namespace Music
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/core/common.hpp>
namespace PD {
namespace Music {
/**
* Decoder Template class
*/
class Decoder : public SmartCtor<Decoder> {
public:
Decoder() = default;
virtual ~Decoder() = default;
/** Template Init function */
virtual int Init(const std::string& path) = 0;
/** Template deinit function */
virtual void Deinit() = 0;
/** Template function to get sample rate */
virtual u32 GetSampleRate() = 0;
/** template function to get number of channels */
virtual u8 GetChannels() = 0;
/** template function to get buffer size */
virtual size_t GetBufSize() = 0;
/** template decode function */
virtual u64 Decode(u16* buf_address) = 0;
/** template function to get file sanples if exist */
virtual size_t GetFileSamples() = 0;
};
} // namespace Music
} // namespace PD

View File

@ -1,79 +1,79 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/core/common.hpp>
namespace PD {
namespace Music {
/**
* Music Metadata Data Holder
*/
class MetaData {
public:
MetaData() = default;
~MetaData() = default;
/** Getter for name */
std::string Name() const { return name; }
/** Getter for album */
std::string Album() const { return album; }
/** Getter for year */
std::string Year() const { return year; }
/** Getter for Title */
std::string Title() const { return title; }
/** Getter for Artist */
std::string Artist() const { return artist; }
/** Getter for [what is this] */
std::string Mdt() const { return mdt; }
/** Gettr for file path */
std::string Path() const { return path; }
/** Setter for Name */
void Name(const std::string &v) { name = v; }
/** Setter for Album */
void Album(const std::string &v) { album = v; }
/** Settr for Year */
void Year(const std::string &v) { year = v; }
/** Settr for Title */
void Title(const std::string &v) { title = v; }
/** Settr for Artist */
void Artist(const std::string &v) { artist = v; }
/** Settr for [what is this] */
void Mdt(const std::string &v) { mdt = v; }
/** Settr for Path */
void Path(const std::string &v) { path = v; }
private:
const std::string unk = "Unknown";
std::string title = unk;
std::string album = unk;
std::string year = unk;
std::string name = unk;
std::string path = unk;
std::string artist = unk;
std::string mdt = unk;
};
} // namespace Music
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/core/common.hpp>
namespace PD {
namespace Music {
/**
* Music Metadata Data Holder
*/
class MetaData {
public:
MetaData() = default;
~MetaData() = default;
/** Getter for name */
std::string Name() const { return name; }
/** Getter for album */
std::string Album() const { return album; }
/** Getter for year */
std::string Year() const { return year; }
/** Getter for Title */
std::string Title() const { return title; }
/** Getter for Artist */
std::string Artist() const { return artist; }
/** Getter for [what is this] */
std::string Mdt() const { return mdt; }
/** Gettr for file path */
std::string Path() const { return path; }
/** Setter for Name */
void Name(const std::string &v) { name = v; }
/** Setter for Album */
void Album(const std::string &v) { album = v; }
/** Settr for Year */
void Year(const std::string &v) { year = v; }
/** Settr for Title */
void Title(const std::string &v) { title = v; }
/** Settr for Artist */
void Artist(const std::string &v) { artist = v; }
/** Settr for [what is this] */
void Mdt(const std::string &v) { mdt = v; }
/** Settr for Path */
void Path(const std::string &v) { path = v; }
private:
const std::string unk = "Unknown";
std::string title = unk;
std::string album = unk;
std::string year = unk;
std::string name = unk;
std::string path = unk;
std::string artist = unk;
std::string mdt = unk;
};
} // namespace Music
} // namespace PD

View File

@ -1,62 +1,62 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <mpg123.h>
#include <pd/sound/decoder.hpp>
namespace PD {
namespace Music {
/**
* MP3 Decoder
*/
class Mp3Decoder : public Decoder {
public:
Mp3Decoder() = default;
~Mp3Decoder() = default;
/** Init Funciton to load file and Init decoder */
int Init(const std::string& path) override;
/** Unload Decoder */
void Deinit() override;
/** Get Sample Rate */
u32 GetSampleRate() override;
/** Get Channels */
u8 GetChannels() override;
/** Get Buffer Size */
size_t GetBufSize() override;
/** Decode next data */
u64 Decode(u16* buf_address) override;
/** Get File Samples if exist */
size_t GetFileSamples() override;
private:
mpg123_handle* handle = nullptr;
size_t buf_size = 0;
u32 rate = 0;
u8 channels = 0;
};
} // namespace Music
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <mpg123.h>
#include <pd/sound/decoder.hpp>
namespace PD {
namespace Music {
/**
* MP3 Decoder
*/
class Mp3Decoder : public Decoder {
public:
Mp3Decoder() = default;
~Mp3Decoder() = default;
/** Init Funciton to load file and Init decoder */
int Init(const std::string& path) override;
/** Unload Decoder */
void Deinit() override;
/** Get Sample Rate */
u32 GetSampleRate() override;
/** Get Channels */
u8 GetChannels() override;
/** Get Buffer Size */
size_t GetBufSize() override;
/** Decode next data */
u64 Decode(u16* buf_address) override;
/** Get File Samples if exist */
size_t GetFileSamples() override;
private:
mpg123_handle* handle = nullptr;
size_t buf_size = 0;
u32 rate = 0;
u8 channels = 0;
};
} // namespace Music
} // namespace PD

View File

@ -1,55 +1,55 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/lib3ds/memory.hpp>
#include <pd/sound/decoder.hpp>
#include <pd/sound/metadata.hpp>
namespace PD {
namespace Music {
/**
* Music Player
*/
class Player : public SmartCtor<Player> {
public:
Player() {}
~Player() {}
private:
MetaData meta;
size_t samples_total = 0;
size_t samples_played = 0;
size_t samples_per_sec = 0;
std::string file;
std::vector<signed short, LinearAllocator<signed short>> buffers[2];
ndspWaveBuf wave_buf[2] = {0};
bool last_buf = false;
int ret = -1;
bool done = false;
bool playing = false;
bool stop = false;
};
} // namespace Music
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/lib3ds/memory.hpp>
#include <pd/sound/decoder.hpp>
#include <pd/sound/metadata.hpp>
namespace PD {
namespace Music {
/**
* Music Player
*/
class Player : public SmartCtor<Player> {
public:
Player() {}
~Player() {}
private:
MetaData meta;
size_t samples_total = 0;
size_t samples_played = 0;
size_t samples_per_sec = 0;
std::string file;
std::vector<signed short, LinearAllocator<signed short>> buffers[2];
ndspWaveBuf wave_buf[2] = {0};
bool last_buf = false;
int ret = -1;
bool done = false;
bool playing = false;
bool stop = false;
};
} // namespace Music
} // namespace PD