aboutsummaryrefslogtreecommitdiff
path: root/src/raylib.h
diff options
context:
space:
mode:
authorJoshua Reisenauer <kd7tck@msn.com>2016-04-29 23:00:12 -0700
committerJoshua Reisenauer <kd7tck@msn.com>2016-04-29 23:00:12 -0700
commit91f1f324c0ee3bd57ed778b39fd54d97330dba32 (patch)
tree40981fe0192075ee3488b5c176d093c5bb2439a8 /src/raylib.h
parentf707c1ca468ef3243808ec87a0b6a891f6c6a130 (diff)
downloadraylib-91f1f324c0ee3bd57ed778b39fd54d97330dba32.tar.gz
raylib-91f1f324c0ee3bd57ed778b39fd54d97330dba32.zip
First stage of audio API update
Look over changes and give feedback please.
Diffstat (limited to 'src/raylib.h')
-rw-r--r--src/raylib.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/raylib.h b/src/raylib.h
index 699fbbdb..1721c009 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -265,6 +265,8 @@
typedef enum { false, true } bool;
#endif
#endif
+typedef enum { silence, mono, stereo } channel_t;
+typedef enum { mixA, mixB, mixC, mixD } mix_t; // Used for mixing/muxing up to four diferent audio streams
// byte type
typedef unsigned char byte;
@@ -446,6 +448,16 @@ typedef struct Wave {
short channels;
} Wave;
+// Audio Context, used to create custom audio streams that are not bound to a sound file. There can be
+// no more than 4 concurrent audio contexts in use. This is due to each active context being tied to
+// a dedicated mix channel.
+typedef struct AudioContext {
+ unsigned short sampleRate; // default is 48000
+ unsigned char bitsPerSample; // 16 is default
+ mix_t mixChannel; // 0-3 or mixA-mixD, each mix channel can receive up to one dedicated audio stream
+ channel_t channels; // 1=mono, 2=stereo
+} AudioContext;
+
// Texture formats
// NOTE: Support depends on OpenGL version and platform
typedef enum {
@@ -863,6 +875,13 @@ void DrawPhysicObjectInfo(PhysicObject *pObj, Vector2 position, int fontSize);
//------------------------------------------------------------------------------------
void InitAudioDevice(void); // Initialize audio device and context
void CloseAudioDevice(void); // Close the audio device and context (and music stream)
+bool AudioDeviceReady(void); // True if call to InitAudioDevice() was successful and CloseAudioDevice() has not been called yet
+
+// Audio contexts are for outputing custom audio waveforms, This will shut down any other sound sources currently playing
+// The mix_t is what mix channel you want to operate on, mixA->mixD are the ones available. Each mix channel can only be used one at a time.
+// exmple usage is InitAudioContext(48000, 16, mixA, stereo);
+AudioContext* InitAudioContext(unsigned short sampleRate, unsigned char bitsPerSample, mix_t mixChannel, channel_t channels);
+void CloseAudioContext(AudioContext *ctx); // Frees audio context
Sound LoadSound(char *fileName); // Load sound to memory
Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data