45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
// Copyright (c) 2023 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#pragma once
|
|
#include "../Asset.hpp"
|
|
#include "asset/AssetLoader.hpp"
|
|
|
|
namespace Dawn {
|
|
class AudioSource;
|
|
|
|
enum AudioAssetLoadState {
|
|
AUDIO_ASSET_LOAD_STATE_INITIAL,
|
|
AUDIO_ASSET_LOAD_STATE_OPENING,
|
|
AUDIO_ASSET_LOAD_STATE_READING_HEADER,
|
|
AUDIO_ASSET_LOAD_STATE_READING_CHANNEL_COUNT,
|
|
AUDIO_ASSET_LOAD_STATE_READING_SAMPLE_RATE,
|
|
AUDIO_ASSET_LOAD_STATE_READING_SAMPLES_PER_CHANNEL,
|
|
AUDIO_ASSET_LOAD_STATE_READING_DATA_LENGTH,
|
|
AUDIO_ASSET_LOAD_STATE_DATA_READ,
|
|
AUDIO_ASSET_LOAD_STATE_COMPLETE
|
|
};
|
|
|
|
class AudioAsset : public Asset {
|
|
protected:
|
|
AssetLoader loader;
|
|
enum AudioAssetLoadState state = AUDIO_ASSET_LOAD_STATE_INITIAL;
|
|
|
|
int32_t channelCount;
|
|
uint32_t sampleRate;
|
|
int32_t samplesPerChannel;
|
|
size_t bufferSize;
|
|
size_t bufferStart;
|
|
size_t frameSize;
|
|
|
|
public:
|
|
AudioAsset(const std::string name);
|
|
|
|
void updateSync() override;
|
|
void updateAsync() override;
|
|
|
|
friend class AudioSource;
|
|
};
|
|
} |