Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
d2920b18
Commit
d2920b18
authored
Oct 14, 2016
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit.
parents
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
0 deletions
+91
-0
README.md
README.md
+91
-0
mini_al.h
mini_al.h
+0
-0
No files found.
README.md
0 → 100644
View file @
d2920b18
mini_al - Mini Audio Library
============================
mini_al is a simple library for playing and recording audio. It's focused on simplicity and has
a very small number of APIs. This is not a full-featured audio library, nor will it ever be. It
is intended to be used as a quick and easy way to connect to an audio device and deliver and
capture audio data from speakers and microphones.
C/C++, single file, public domain.
Features
========
-
A very simple API.
-
Both synchronous and asynchronous APIs.
Examples
========
Asynchonous API
---------------
In asynchronous mode, mini_al will request and deliver audio data through callbacks.
```
mal_uint32 on_send_audio_data(mal_device* pDevice, mal_uint32 sampleCount, void* pSamples)
{
return drwav_read_f32((drwav*)pDevice->pUserData, sampleCount, pSamples);
}
int main()
{
mal_uint32 channels = 2;
mal_uint32 sampleRate = 44100;
mal_uint32 fragmentSizeInFrames = 512;
mal_uint32 fragmentCount = 2;
mal_device playbackDevice;
if (mal_device_init(&playbackDevice, mal_device_type_playback, NULL, mal_format_f32, channels, sampleRate, fragmentSizeInFrames, fragmentCount) != MAL_SUCCESS) {
return -1;
}
mal_device_set_send_callback(&playbackDevice, on_send_audio_data);
mal_device_start(&playbackDevice);
printf("Press Enter to quit...\n");
getchar();
mal_device_uninit(&playbackDevice);
return 0;
}
```
Synchronous API
---------------
In synchronous mode, the application submits audio data to the device using APIs which block until
the device is ready to receive it.
```
int main()
{
mal_uint32 channels = 2;
mal_uint32 sampleRate = 44100;
mal_uint32 fragmentSizeInFrames = 512;
mal_uint32 fragmentCount = 2;
mal_device playbackDevice;
if (mal_device_init_synchronous(&playbackDevice, mal_device_type_playback, NULL, mal_format_f32, channels, sampleRate, fragmentSizeInFrames, fragmentCount) != MAL_SUCCESS) {
return -1;
}
mal_device_start(&playbackDevice);
for (;;) {
float pSamples[512];
mal_uint32 samplesToWrite = drwav_read_f32(&wav, fragmentSizeInFrames * fragmentCount, pSamples);
if (samplesToWrite == 0) {
break;
}
mal_uint32 samplesWritten = mal_device_write(&playbackDevice, samplesToWrite, pSamples);
if (samplesWritte != samplesToWrite) {
break;
}
}
mal_device_uninit(&playbackDevice);
return 0;
}
```
\ No newline at end of file
mini_al.h
0 → 100644
View file @
d2920b18
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment