| 1 | /** |
| 2 | * Copyright (c) 2006-2023 LOVE Development Team |
| 3 | * |
| 4 | * This software is provided 'as-is', without any express or implied |
| 5 | * warranty. In no event will the authors be held liable for any damages |
| 6 | * arising from the use of this software. |
| 7 | * |
| 8 | * Permission is granted to anyone to use this software for any purpose, |
| 9 | * including commercial applications, and to alter it and redistribute it |
| 10 | * freely, subject to the following restrictions: |
| 11 | * |
| 12 | * 1. The origin of this software must not be misrepresented; you must not |
| 13 | * claim that you wrote the original software. If you use this software |
| 14 | * in a product, an acknowledgment in the product documentation would be |
| 15 | * appreciated but is not required. |
| 16 | * 2. Altered source versions must be plainly marked as such, and must not be |
| 17 | * misrepresented as being the original software. |
| 18 | * 3. This notice may not be removed or altered from any source distribution. |
| 19 | **/ |
| 20 | |
| 21 | #ifndef LOVE_SOUND_SOUND_DATA_H |
| 22 | #define LOVE_SOUND_SOUND_DATA_H |
| 23 | |
| 24 | // LOVE |
| 25 | #include "filesystem/File.h" |
| 26 | #include "common/int.h" |
| 27 | #include "Decoder.h" |
| 28 | |
| 29 | namespace love |
| 30 | { |
| 31 | namespace sound |
| 32 | { |
| 33 | |
| 34 | class SoundData : public love::Data |
| 35 | { |
| 36 | public: |
| 37 | |
| 38 | static love::Type type; |
| 39 | |
| 40 | SoundData(Decoder *decoder); |
| 41 | SoundData(int samples, int sampleRate, int bitDepth, int channels); |
| 42 | SoundData(void *d, int samples, int sampleRate, int bitDepth, int channels); |
| 43 | SoundData(const SoundData &c); |
| 44 | |
| 45 | virtual ~SoundData(); |
| 46 | |
| 47 | // Implements Data. |
| 48 | SoundData *clone() const; |
| 49 | void *getData() const; |
| 50 | size_t getSize() const; |
| 51 | |
| 52 | virtual int getChannelCount() const; |
| 53 | virtual int getBitDepth() const; |
| 54 | virtual int getSampleRate() const; |
| 55 | virtual int getSampleCount() const; |
| 56 | |
| 57 | virtual float getDuration() const; |
| 58 | |
| 59 | void setSample(int i, float sample); |
| 60 | void setSample(int i, int channel, float sample); |
| 61 | float getSample(int i) const; |
| 62 | float getSample(int i, int channel) const; |
| 63 | |
| 64 | private: |
| 65 | |
| 66 | void load(int samples, int sampleRate, int bitDepth, int channels, void *newData = 0); |
| 67 | |
| 68 | uint8 *data; |
| 69 | size_t size; |
| 70 | |
| 71 | int sampleRate; |
| 72 | int bitDepth; |
| 73 | int channels; |
| 74 | |
| 75 | }; // SoundData |
| 76 | |
| 77 | } // sound |
| 78 | } // love |
| 79 | |
| 80 | #endif // LOVE_SOUND_SOUND_DATA_H |
| 81 | |