mirror of https://github.com/McSinyx/palace
Compare commits
2 Commits
1ba92b7c50
...
708f23b35a
Author | SHA1 | Date |
---|---|---|
Ngô Ngọc Đức Huy | 708f23b35a | |
Nguyễn Gia Phong | c5861833ab |
|
@ -138,3 +138,6 @@ dmypy.json
|
||||||
\#*\#
|
\#*\#
|
||||||
.\#*
|
.\#*
|
||||||
*~
|
*~
|
||||||
|
|
||||||
|
# VS Code
|
||||||
|
.vscode/
|
||||||
|
|
|
@ -38,7 +38,6 @@ Indices and Tables
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
* :ref:`genindex`
|
* :ref:`genindex`
|
||||||
* :ref:`modindex`
|
|
||||||
* :ref:`search`
|
* :ref:`search`
|
||||||
|
|
||||||
.. _HRTF: https://en.wikipedia.org/wiki/Head-related_transfer_function
|
.. _HRTF: https://en.wikipedia.org/wiki/Head-related_transfer_function
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
Adding an Effect
|
||||||
|
================
|
||||||
|
|
||||||
|
.. currentmodule:: palace
|
||||||
|
|
||||||
|
This section will focus on how to add effects to the audio.
|
||||||
|
|
||||||
|
There are two set of audio effects supported by palace: :py:class:`ReverbEffect`
|
||||||
|
and :py:class:`ChorusEffect`.
|
||||||
|
|
||||||
|
Reverb Effect
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Reverb happens when a sound is reflected and then decay as the sound is absorbed
|
||||||
|
by the objects in the medium. :py:class:`ReverbEffect` facilitates such effect.
|
||||||
|
|
||||||
|
Creating a reverb effect can be as simple as:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
with ReverbEffect() as effect:
|
||||||
|
source.sends[0].effect = effect
|
||||||
|
|
||||||
|
:py:attr:`Source.sends` is a collection of send path signals, each of which
|
||||||
|
contains `effects` and `filter` that describes it. Here we are only concerned
|
||||||
|
about the former.
|
||||||
|
|
||||||
|
The above code would yield a *generic* reverb effect by default.
|
||||||
|
There are several other presets that you can use, which are listed
|
||||||
|
by :py:data:`reverb_preset_names`. To use these preset, you can simply provide
|
||||||
|
the preset effect name as the first parameter for the constructor. For example,
|
||||||
|
to use `PIPE_LARGE` preset effect, you can initialize the effect like below:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
with ReverbEffect('PIPE_LARGE') as effect:
|
||||||
|
source.sends[0].effect = effect
|
||||||
|
|
||||||
|
These effects can be modified via their attributes.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
effect.gain = 0.4
|
||||||
|
effect.diffusion = 0.65
|
||||||
|
late_reverb_pan = 0.2, 0.1, 0.3
|
||||||
|
|
||||||
|
The list of these attributes and their constraints can be found
|
||||||
|
in the documentation of :py:class:`ReverbEffect`.
|
||||||
|
|
||||||
|
Chorus Effect
|
||||||
|
-------------
|
||||||
|
|
||||||
|
:py:class:`ChorusEffect` does not have preset effects like
|
||||||
|
:py:class:`ReverbEffect`, so you would have to initialize the effect attributes
|
||||||
|
on creation.
|
||||||
|
|
||||||
|
There are five parameters to initialize the effect, respectively: waveform,
|
||||||
|
phase, depth, feedback, and delay.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
with ChorusEffect('sine', 20, 0.4, 0.5, 0.008) as effect:
|
||||||
|
source.sends[0].effect = effect
|
||||||
|
|
||||||
|
For the constraints of these parameters, please refer to the documentation.
|
|
@ -9,7 +9,7 @@ This tutorial will guide you on:
|
||||||
context
|
context
|
||||||
play-audio
|
play-audio
|
||||||
source
|
source
|
||||||
|
effect
|
||||||
.. comment these to add later
|
.. comment these to add later
|
||||||
Adding effects
|
|
||||||
Customize decoder
|
Customize decoder
|
||||||
Generate sounds
|
Generate sounds
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = palace
|
name = palace
|
||||||
version = 0.2.1
|
version = 0.2.2
|
||||||
url = https://mcsinyx.github.io/palace
|
url = https://mcsinyx.github.io/palace
|
||||||
author = Nguyễn Gia Phong
|
author = Nguyễn Gia Phong
|
||||||
author_email = mcsinyx@disroot.org
|
author_email = mcsinyx@disroot.org
|
||||||
|
|
|
@ -632,8 +632,8 @@ cdef class Device:
|
||||||
def clock_time(self) -> int:
|
def clock_time(self) -> int:
|
||||||
"""Current clock time for the device.
|
"""Current clock time for the device.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
This starts relative to the device being opened, and does not
|
This starts relative to the device being opened, and does not
|
||||||
increment while there are no contexts nor while processing
|
increment while there are no contexts nor while processing
|
||||||
is paused. Currently, this may not exactly match the rate
|
is paused. Currently, this may not exactly match the rate
|
||||||
|
@ -1086,8 +1086,8 @@ cdef class Buffer:
|
||||||
def size(self) -> int:
|
def size(self) -> int:
|
||||||
"""Storage size used by the buffer, in bytes.
|
"""Storage size used by the buffer, in bytes.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
The size in bytes may not be what you expect from the length,
|
The size in bytes may not be what you expect from the length,
|
||||||
as it may take more space internally than the `channel_config`
|
as it may take more space internally than the `channel_config`
|
||||||
and `sample_type` suggest.
|
and `sample_type` suggest.
|
||||||
|
@ -1121,8 +1121,8 @@ cdef class Buffer:
|
||||||
end : int
|
end : int
|
||||||
Ending point, in sample frames (exclusive).
|
Ending point, in sample frames (exclusive).
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
The buffer must not be in use when this property is set.
|
The buffer must not be in use when this property is set.
|
||||||
"""
|
"""
|
||||||
return self.impl.get_loop_points()
|
return self.impl.get_loop_points()
|
||||||
|
@ -1146,8 +1146,8 @@ cdef class Buffer:
|
||||||
def source_count(self) -> int:
|
def source_count(self) -> int:
|
||||||
"""Number of sources currently using the buffer.
|
"""Number of sources currently using the buffer.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
`Context.update` needs to be called to reliably ensure the count
|
`Context.update` needs to be called to reliably ensure the count
|
||||||
is kept updated for when sources reach their end. This is
|
is kept updated for when sources reach their end. This is
|
||||||
equivalent to calling `len(self.sources)`.
|
equivalent to calling `len(self.sources)`.
|
||||||
|
@ -1475,8 +1475,8 @@ cdef class Source:
|
||||||
up : Tuple[float, float, float]
|
up : Tuple[float, float, float]
|
||||||
Relative direction.
|
Relative direction.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
Unlike `AL_EXT_BFORMAT` extension this property
|
Unlike `AL_EXT_BFORMAT` extension this property
|
||||||
comes from, this also affects the facing direction.
|
comes from, this also affects the facing direction.
|
||||||
"""
|
"""
|
||||||
|
@ -1508,8 +1508,8 @@ cdef class Source:
|
||||||
If set to a value where `inner` is greater than `outer`
|
If set to a value where `inner` is greater than `outer`
|
||||||
or either of them is outside of the [0, 360] interval.
|
or either of them is outside of the [0, 360] interval.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
The areas follow the facing direction, so for example
|
The areas follow the facing direction, so for example
|
||||||
an inner angle of 180 means the entire front face of
|
an inner angle of 180 means the entire front face of
|
||||||
the source is in the inner cone.
|
the source is in the inner cone.
|
||||||
|
@ -2543,8 +2543,8 @@ cdef class Decoder:
|
||||||
--------
|
--------
|
||||||
Buffer : Preloaded PCM samples coming from a `Decoder`
|
Buffer : Preloaded PCM samples coming from a `Decoder`
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
Due to implementation details, while this creates decoder objects
|
Due to implementation details, while this creates decoder objects
|
||||||
from filenames using contexts, it is the superclass of the ABC
|
from filenames using contexts, it is the superclass of the ABC
|
||||||
(abstract base class) `BaseDecoder`. Because of this, `Decoder`
|
(abstract base class) `BaseDecoder`. Because of this, `Decoder`
|
||||||
|
@ -2580,8 +2580,8 @@ cdef class Decoder:
|
||||||
def length(self) -> int:
|
def length(self) -> int:
|
||||||
"""Length of audio in sample frames, falling-back to 0.
|
"""Length of audio in sample frames, falling-back to 0.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
Zero-length decoders may not be used to load a `Buffer`.
|
Zero-length decoders may not be used to load a `Buffer`.
|
||||||
"""
|
"""
|
||||||
return self.pimpl.get()[0].get_length()
|
return self.pimpl.get()[0].get_length()
|
||||||
|
@ -2590,8 +2590,8 @@ cdef class Decoder:
|
||||||
def length_seconds(self) -> float:
|
def length_seconds(self) -> float:
|
||||||
"""Length of audio in seconds, falling-back to 0.0.
|
"""Length of audio in seconds, falling-back to 0.0.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
Zero-length decoders may not be used to load a `Buffer`.
|
Zero-length decoders may not be used to load a `Buffer`.
|
||||||
"""
|
"""
|
||||||
return self.length / self.frequency
|
return self.length / self.frequency
|
||||||
|
@ -2614,8 +2614,8 @@ cdef class Decoder:
|
||||||
end : int
|
end : int
|
||||||
Exclusive starting loop point.
|
Exclusive starting loop point.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
If `start >= end`, all available samples are included
|
If `start >= end`, all available samples are included
|
||||||
in the loop.
|
in the loop.
|
||||||
"""
|
"""
|
||||||
|
@ -2715,8 +2715,8 @@ class BaseDecoder(_BaseDecoder, metaclass=ABCMeta):
|
||||||
def length(self) -> int:
|
def length(self) -> int:
|
||||||
"""Length of audio in sample frames, falling-back to 0.
|
"""Length of audio in sample frames, falling-back to 0.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
Zero-length decoders may not be used to load a `Buffer`.
|
Zero-length decoders may not be used to load a `Buffer`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -2739,8 +2739,8 @@ class BaseDecoder(_BaseDecoder, metaclass=ABCMeta):
|
||||||
end : int
|
end : int
|
||||||
Exclusive starting loop point.
|
Exclusive starting loop point.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
If `start >= end`, all available samples are included
|
If `start >= end`, all available samples are included
|
||||||
in the loop.
|
in the loop.
|
||||||
"""
|
"""
|
||||||
|
@ -2814,8 +2814,8 @@ class FileIO(Protocol):
|
||||||
Many classes defined in the standard library module `io`
|
Many classes defined in the standard library module `io`
|
||||||
are compatible with this protocol.
|
are compatible with this protocol.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
Since PEP 544 is only implemented in Python 3.8+, type checking
|
Since PEP 544 is only implemented in Python 3.8+, type checking
|
||||||
for this on earlier Python version might not work as expected.
|
for this on earlier Python version might not work as expected.
|
||||||
"""
|
"""
|
||||||
|
@ -2911,8 +2911,8 @@ cdef class MessageHandler:
|
||||||
attempted to play will immediately stop, and new contexts may
|
attempted to play will immediately stop, and new contexts may
|
||||||
not be created on the device.
|
not be created on the device.
|
||||||
|
|
||||||
Notes
|
Note
|
||||||
-----
|
----
|
||||||
Connection status is checked during `Context.update` calls, so
|
Connection status is checked during `Context.update` calls, so
|
||||||
method must be called regularly to be notified when a device is
|
method must be called regularly to be notified when a device is
|
||||||
disconnected. This method may not be called if the device lacks
|
disconnected. This method may not be called if the device lacks
|
||||||
|
|
Loading…
Reference in New Issue