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
f4693be9
Commit
f4693be9
authored
Mar 05, 2019
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Emscripten simple playback example.
parent
2e23db7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
examples/simple_playback_emscripten.c
examples/simple_playback_emscripten.c
+13
-7
No files found.
examples/simple_playback_emscripten.c
View file @
f4693be9
...
...
@@ -15,15 +15,15 @@ void main_loop__em()
#define DEVICE_CHANNELS 1
#define DEVICE_SAMPLE_RATE 48000
// This is the function that's used for sending more data to the device for playback.
mal_uint32
on_send_frames_to_device
(
mal_device
*
pDevice
,
mal_uint32
frameCount
,
void
*
pSamples
)
void
data_callback
(
mal_device
*
pDevice
,
void
*
pOutput
,
const
void
*
pInput
,
mal_uint32
frameCount
)
{
mal_assert
(
pDevice
->
channels
==
DEVICE_CHANNELS
);
(
void
)
pInput
;
/* Unused. */
mal_assert
(
pDevice
->
playback
.
channels
==
DEVICE_CHANNELS
);
mal_sine_wave
*
pSineWave
=
(
mal_sine_wave
*
)
pDevice
->
pUserData
;
mal_assert
(
pSineWave
!=
NULL
);
return
mal_sine_wave_read
(
pSineWave
,
frameCount
,
(
float
*
)
pSamples
);
mal_sine_wave_read_f32
(
pSineWave
,
frameCount
,
(
float
*
)
pOutput
);
}
int
main
(
int
argc
,
char
**
argv
)
...
...
@@ -34,14 +34,20 @@ int main(int argc, char** argv)
mal_sine_wave
sineWave
;
mal_sine_wave_init
(
0
.
2
,
400
,
DEVICE_SAMPLE_RATE
,
&
sineWave
);
mal_device_config
config
=
mal_device_config_init_playback
(
DEVICE_FORMAT
,
DEVICE_CHANNELS
,
DEVICE_SAMPLE_RATE
,
on_send_frames_to_device
,
&
sineWave
);
mal_device_config
config
=
mal_device_config_init
(
mal_device_type_playback
);
config
.
playback
.
format
=
DEVICE_FORMAT
;
config
.
playback
.
channels
=
DEVICE_CHANNELS
;
config
.
sampleRate
=
DEVICE_SAMPLE_RATE
;
config
.
dataCallback
=
data_callback
;
config
.
pUserData
=
&
sineWave
;
mal_device
device
;
if
(
mal_device_init
(
NULL
,
mal_device_type_playback
,
NULL
,
&
config
,
&
device
)
!=
MAL_SUCCESS
)
{
if
(
mal_device_init
(
NULL
,
&
config
,
&
device
)
!=
MAL_SUCCESS
)
{
printf
(
"Failed to open playback device.
\n
"
);
return
-
4
;
}
printf
(
"Device Name: %s
\n
"
,
device
.
name
);
printf
(
"Device Name: %s
\n
"
,
device
.
playback
.
name
);
if
(
mal_device_start
(
&
device
)
!=
MAL_SUCCESS
)
{
printf
(
"Failed to start playback device.
\n
"
);
...
...
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