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
13441af6
Commit
13441af6
authored
Aug 12, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mal_sine_wave_read_ex().
parent
22240e51
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
mini_al.h
mini_al.h
+24
-7
tests/mal_unplugging.c
tests/mal_unplugging.c
+3
-5
No files found.
mini_al.h
View file @
13441af6
...
...
@@ -2632,8 +2632,9 @@ typedef struct
double time;
} mal_sine_wave;
mal_result mal_sine_wave_init(double amplitude, double period, mal_uint32 sampleRate, mal_sine_wave* pSignWave);
mal_uint64 mal_sine_wave_read(mal_sine_wave* pSignWave, mal_uint64 count, float* pSamples);
mal_result mal_sine_wave_init(double amplitude, double period, mal_uint32 sampleRate, mal_sine_wave* pSineWave);
mal_uint64 mal_sine_wave_read(mal_sine_wave* pSineWave, mal_uint64 count, float* pSamples);
mal_uint64 mal_sine_wave_read_ex(mal_sine_wave* pSineWave, mal_uint64 frameCount, mal_uint32 channels, mal_stream_layout layout, float** ppFrames);
#ifdef __cplusplus
...
...
@@ -27354,21 +27355,36 @@ mal_result mal_sine_wave_init(double amplitude, double periodsPerSecond, mal_uin
}
mal_uint64 mal_sine_wave_read(mal_sine_wave* pSineWave, mal_uint64 count, float* pSamples)
{
return mal_sine_wave_read_ex(pSineWave, count, 1, mal_stream_layout_interleaved, &pSamples);
}
mal_uint64 mal_sine_wave_read_ex(mal_sine_wave* pSineWave, mal_uint64 frameCount, mal_uint32 channels, mal_stream_layout layout, float** ppFrames)
{
if (pSineWave == NULL) {
return 0;
}
if (p
Sampl
es != NULL) {
for (mal_uint64 i
= 0; i < count; i
+= 1) {
pSamples[i]
= (float)(sin(pSineWave->time * pSineWave->periodsPerSecond) * pSineWave->amplitude);
if (p
pFram
es != NULL) {
for (mal_uint64 i
Frame = 0; iFrame < frameCount; iFrame
+= 1) {
float s
= (float)(sin(pSineWave->time * pSineWave->periodsPerSecond) * pSineWave->amplitude);
pSineWave->time += pSineWave->delta;
if (layout == mal_stream_layout_interleaved) {
for (mal_uint32 iChannel = 0; iChannel < channels; iChannel += 1) {
ppFrames[0][iFrame*channels + iChannel] = s;
}
} else {
for (mal_uint32 iChannel = 0; iChannel < channels; iChannel += 1) {
ppFrames[iChannel][iFrame] = s;
}
}
}
} else {
pSineWave->time += pSineWave->delta *
c
ount;
pSineWave->time += pSineWave->delta *
frameC
ount;
}
return
c
ount;
return
frameC
ount;
}
...
...
@@ -27387,6 +27403,7 @@ mal_uint64 mal_sine_wave_read(mal_sine_wave* pSineWave, mal_uint64 count, float*
// Raspberry Pi experience.
// - Fix a bug where an incorrect number of samples is returned from sinc resampling.
// - Add support for setting the value to be passed to internal calls to CoInitializeEx().
// - WASAPI and WinMM: Stop the device when it is unplugged.
//
// v0.8.4 - 2018-08-06
// - Add sndio backend for OpenBSD.
tests/mal_unplugging.c
View file @
13441af6
...
...
@@ -24,16 +24,14 @@ void on_stop(mal_device* pDevice)
mal_uint32
on_send
(
mal_device
*
pDevice
,
mal_uint32
frameCount
,
void
*
pFramesOut
)
{
mal_assert
(
pDevice
!=
NULL
);
mal_assert
(
pDevice
->
channels
==
1
);
(
void
)
pDevice
;
//printf("TESTING: %d\n", frameCount);
return
(
mal_uint32
)
mal_sine_wave_read
(
&
g_sineWave
,
frameCount
,
(
float
*
)
pFramesOut
);
return
(
mal_uint32
)
mal_sine_wave_read
_ex
(
&
g_sineWave
,
frameCount
,
pDevice
->
channels
,
mal_stream_layout_interleaved
,
(
float
**
)
&
pFramesOut
);
}
int
main
()
{
mal_backend
backend
=
mal_backend_
alsa
;
mal_backend
backend
=
mal_backend_
wasapi
;
mal_result
result
=
mal_sine_wave_init
(
0
.
25
f
,
400
,
48000
,
&
g_sineWave
);
if
(
result
!=
MAL_SUCCESS
)
{
...
...
@@ -42,7 +40,7 @@ int main()
}
mal_context_config
contextConfig
=
mal_context_config_init
(
on_log
);
mal_device_config
deviceConfig
=
mal_device_config_init_playback
(
mal_format_f32
,
1
,
48000
,
on_send
);
mal_device_config
deviceConfig
=
mal_device_config_init_playback
(
mal_format_f32
,
0
,
48000
,
on_send
);
deviceConfig
.
onStopCallback
=
on_stop
;
mal_device
device
;
...
...
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