CSFML

- Main Page
- Data Structures
- Files

- File List
- Globals

Functions
SoundBuffer.h File Reference
`#include <SFML/Audio/Export.h>`
`#include <SFML/Audio/Types.h>`
`#include <SFML/System/InputStream.h>`
`#include <SFML/System/Time.h>`
`#include <stddef.h>`

Go to the source code of this file.

## Functions
CSFML_AUDIO_API sfSoundBuffer * | sfSoundBuffer_createFromFile (const char *filename)
| Create a new sound buffer and load it from a file. More...
CSFML_AUDIO_API sfSoundBuffer * | sfSoundBuffer_createFromMemory (const void *data, size_t sizeInBytes)
| Create a new sound buffer and load it from a file in memory. More...
CSFML_AUDIO_API sfSoundBuffer * | sfSoundBuffer_createFromStream (sfInputStream *stream)
| Create a new sound buffer and load it from a custom stream. More...
CSFML_AUDIO_API sfSoundBuffer * | sfSoundBuffer_createFromSamples (const sfInt16 *samples, size_t sampleCount, unsigned int channelCount, unsigned int sampleRate)
| Create a new sound buffer and load it from an array of samples in memory. More...
CSFML_AUDIO_API sfSoundBuffer * | sfSoundBuffer_copy (const sfSoundBuffer *soundBuffer)
| Create a new sound buffer by copying an existing one. More...
CSFML_AUDIO_API void | sfSoundBuffer_destroy (sfSoundBuffer *soundBuffer)
| Destroy a sound buffer. More...
CSFML_AUDIO_API sfBool | sfSoundBuffer_saveToFile (const sfSoundBuffer *soundBuffer, const char *filename)
| Save a sound buffer to an audio file. More...
CSFML_AUDIO_API const sfInt16 * | sfSoundBuffer_getSamples (const sfSoundBuffer *soundBuffer)
| Get the array of audio samples stored in a sound buffer. More...
CSFML_AUDIO_API size_t | sfSoundBuffer_getSampleCount (const sfSoundBuffer *soundBuffer)
| Get the number of samples stored in a sound buffer. More...
CSFML_AUDIO_API unsigned int | sfSoundBuffer_getSampleRate (const sfSoundBuffer *soundBuffer)
| Get the sample rate of a sound buffer. More...
CSFML_AUDIO_API unsigned int | sfSoundBuffer_getChannelCount (const sfSoundBuffer *soundBuffer)
| Get the number of channels used by a sound buffer. More...
CSFML_AUDIO_API sfTime | sfSoundBuffer_getDuration (const sfSoundBuffer *soundBuffer)
| Get the total duration of a sound buffer. More...

## Function Documentation

CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_copy | ( | const sfSoundBuffer * | soundBuffer) |  |

Create a new sound buffer by copying an existing one.

Parameters

  soundBuffer | Sound buffer to copy

Returns
  A new sfSoundBuffer object which is a copy of soundBuffer

CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromFile | ( | const char * | filename) |  |

Create a new sound buffer and load it from a file.

Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.

Parameters

  filename | Path of the sound file to load

Returns
  A new sfSoundBuffer object (NULL if failed)

CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromMemory | ( | const void * | data,
|  | size_t | sizeInBytes
| ) |  |

Create a new sound buffer and load it from a file in memory.

Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.

Parameters

  data | Pointer to the file data in memory
  sizeInBytes | Size of the data to load, in bytes

Returns
  A new sfSoundBuffer object (NULL if failed)

CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples | ( | const sfInt16 * | samples,
|  | size_t | sampleCount,
|  | unsigned int | channelCount,
|  | unsigned int | sampleRate
| ) |  |

Create a new sound buffer and load it from an array of samples in memory.

The assumed format of the audio samples is 16 bits signed integer (sfInt16).

Parameters

  samples | Pointer to the array of samples in memory
  sampleCount | Number of samples in the array
  channelCount | Number of channels (1 = mono, 2 = stereo, ...)
  sampleRate | Sample rate (number of samples to play per second)

Returns
  A new sfSoundBuffer object (NULL if failed)

CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromStream | ( | sfInputStream * | stream) |  |

Create a new sound buffer and load it from a custom stream.

Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.

Parameters

  stream | Source stream to read from

Returns
  A new sfSoundBuffer object (NULL if failed)

CSFML_AUDIO_API void sfSoundBuffer_destroy | ( | sfSoundBuffer * | soundBuffer) |  |

Destroy a sound buffer.

Parameters

  soundBuffer | Sound buffer to destroy

CSFML_AUDIO_API unsigned int sfSoundBuffer_getChannelCount | ( | const sfSoundBuffer * | soundBuffer) |  |

Get the number of channels used by a sound buffer.

If the sound is mono then the number of channels will be 1, 2 for stereo, etc.

Parameters

  soundBuffer | Sound buffer object

Returns
  Number of channels

CSFML_AUDIO_API sfTime sfSoundBuffer_getDuration | ( | const sfSoundBuffer * | soundBuffer) |  |

Get the total duration of a sound buffer.

Parameters

  soundBuffer | Sound buffer object

Returns
  Sound duration

CSFML_AUDIO_API size_t sfSoundBuffer_getSampleCount | ( | const sfSoundBuffer * | soundBuffer) |  |

Get the number of samples stored in a sound buffer.

The array of samples can be accessed with the sfSoundBuffer_getSamples function.

Parameters

  soundBuffer | Sound buffer object

Returns
  Number of samples

CSFML_AUDIO_API unsigned int sfSoundBuffer_getSampleRate | ( | const sfSoundBuffer * | soundBuffer) |  |

Get the sample rate of a sound buffer.

The sample rate is the number of samples played per second. The higher, the better the quality (for example, 44100 samples/s is CD quality).

Parameters

  soundBuffer | Sound buffer object

Returns
  Sample rate (number of samples per second)

CSFML_AUDIO_API const sfInt16* sfSoundBuffer_getSamples | ( | const sfSoundBuffer * | soundBuffer) |  |

Get the array of audio samples stored in a sound buffer.

The format of the returned samples is 16 bits signed integer (sfInt16). The total number of samples in this array is given by the sfSoundBuffer_getSampleCount function.

Parameters

  soundBuffer | Sound buffer object

Returns
  Read-only pointer to the array of sound samples

CSFML_AUDIO_API sfBool sfSoundBuffer_saveToFile | ( | const sfSoundBuffer * | soundBuffer,
|  | const char * | filename
| ) |  |

Save a sound buffer to an audio file.

Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.

Parameters

  soundBuffer | Sound buffer object
  filename | Path of the sound file to write

Returns
  sfTrue if saving succeeded, sfFalse if it failed