Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
bfef0fbf
Commit
bfef0fbf
authored
Oct 20, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm_volume: implement float samples
parent
545685bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
pcm_volume.c
src/pcm_volume.c
+13
-2
pcm_volume.h
src/pcm_volume.h
+6
-0
No files found.
src/pcm_volume.c
View file @
bfef0fbf
...
...
@@ -132,6 +132,16 @@ pcm_volume_change_32(int32_t *buffer, const int32_t *end, int volume)
}
}
static
void
pcm_volume_change_float
(
float
*
buffer
,
const
float
*
end
,
float
volume
)
{
while
(
buffer
<
end
)
{
float
sample
=
*
buffer
;
sample
*=
volume
;
*
buffer
++
=
sample
;
}
}
bool
pcm_volume
(
void
*
buffer
,
size_t
length
,
enum
sample_format
format
,
...
...
@@ -169,8 +179,9 @@ pcm_volume(void *buffer, size_t length,
return
true
;
case
SAMPLE_FORMAT_FLOAT
:
/* XXX */
return
false
;
pcm_volume_change_float
(
buffer
,
end
,
pcm_volume_to_float
(
volume
));
return
true
;
}
/* unreachable */
...
...
src/pcm_volume.h
View file @
bfef0fbf
...
...
@@ -43,6 +43,12 @@ pcm_float_to_volume(float volume)
return
volume
*
PCM_VOLUME_1
+
0
.
5
;
}
static
inline
float
pcm_volume_to_float
(
int
volume
)
{
return
(
float
)
volume
/
(
float
)
PCM_VOLUME_1
;
}
/**
* Returns the next volume dithering number, between -511 and +511.
* This number is taken from a global PRNG, see pcm_prng().
...
...
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