
#ifndef H_SFL_SOUND_
#define H_SFL_SOUND_

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>

struct sflSound_t;
typedef struct sflSound_t sflSound;

/**
 * Open a sound file. WAV(PCM) and MP3 are available.
 */
sflSound *sflSoundOpen(const char *filename);

/**
 * Read samples from a sound.
 * @param self 
 * @param outbuf
 * @param n
 * @return the number of samples
 */
size_t sflSoundRead(sflSound *self, void *outbuf, size_t n);

// 読み込み位置を whence を基準に offset サンプルだけずれた位置へ変更する
// whence には以下のいずれかを指定する
//     SEEK_SET    先頭
//     SEEK_CUR    現在位置
//     SEEK_END    末尾
// return  0 成功
//        -1 失敗
int sflSoundSeek(sflSound *self, int offset, int whence);

/**
 * Get current position by samples.
 */
long sflSoundTell(sflSound *self);

/**
 * Close a sound
 * @return 0 on success, negative value on error.
 */
int sflSoundClose(sflSound *self);

/**
 * Create clone of a sound.
 */
sflSound *sflSoundClone(sflSound *self);

#ifdef __cplusplus
}
#endif

#endif

