#ifndef MR4TH_SOUND_H
#define MR4TH_SOUND_H

////////////////////////////////
// SOUND: Types

/*
** definitions:
**  value   - one value in a sequence of values forming a channel
**            could be integer of any size, or a float
**            all values in a channel are the same type
**  channel - one (of possibly several) "parallel" sequences of values
**            parallel channels all have the same number of values
**  sample  - a tuple of value, one value for each channel,
**            from the same point in each parallel sequence
*/

typedef U32 SOUND_ValueKind;
enum{
    // [0,0xFFFF] reserved for signed types
    // with bit_size(SOUND_ValueKind_Signed0 + n) = n
    SOUND_ValueKind_Signed0 = (0x0 << 16),
    
    // [0x10000,0x1FFFF] reserved for float types
    // with bit_size(SOUND_ValueKind_Float<n>) = n
    SOUND_ValueKind_Float16 = (0x1 << 16),
    SOUND_ValueKind_Float32,
    SOUND_ValueKind_Float64,
};

typedef struct SOUND_Data{
    void **channels;
    U64 channel_count;
    U64 sample_count;
    U32 samples_per_second;
    U32 bytes_per_value;
    SOUND_ValueKind value_kind;
} SOUND_Data;

////////////////////////////////
// SOUND: Functions

MR4TH_SYMBOL_STATIC DSP_Signal* sound_signal_from_channel(Arena *arena, SOUND_Data *data, U64 channel_idx);

MR4TH_SYMBOL_STATIC void sound_buffer_convert_raw(void *dst, U64 dst_size, SOUND_ValueKind dst_kind,
                                                  void *src, U64 src_size, SOUND_ValueKind src_kind);

#endif //MR4TH_SOUND_H
