Move documentation to docs/

This commit is contained in:
Nguyễn Gia Phong 2020-08-24 16:41:13 +07:00
parent 08408c56c7
commit 9a1dbf5d94
81 changed files with 47 additions and 32498 deletions

View File

View File

@ -1,12 +1,11 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = src
BUILDDIR = .
# You can set these variables from the command line,
# and also from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:

View File

@ -7,8 +7,8 @@ REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=src
set BUILDDIR=.
set SOURCEDIR=source
set BUILDDIR=build
if "%1" == "" goto help

39
docs/source/conf.py Normal file
View File

@ -0,0 +1,39 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options.
# For a full list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# Project information
project = 'palace'
copyright = '2019, 2020 Nguyễn Gia Phong et al'
author = 'Nguyễn Gia Phong et al.'
release = '0.2.1'
# Add any Sphinx extension module names here, as strings.
# They can be extensions coming with Sphinx (named 'sphinx.ext.*')
# or your custom ones.
extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.githubpages', 'sphinx.ext.napoleon']
napoleon_google_docstring = False
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match
# files and directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# Options for HTML output
html_theme = 'alabaster'
html_theme_options = {'fixed_sidebar': True, 'show_relbars': True}
html_sidebars = {
'**': ['globaltoc.html', 'quicknav.html', 'searchbox.html']}
# Add any paths that contain custom static files (such as style sheets)
# here, relative to this directory. They are copied after the builtin
# static files, so a file named "default.css" will overwrite the builtin
# "default.css".
html_static_path = ['_static']

View File

@ -1,4 +0,0 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 15f696dd8f7d3d70ce592a5e4a09ce3d
tags: 645f666f9bcd5a90fca523b33c5a78b7

View File

@ -1,203 +0,0 @@
Getting Involved
================
.. note:: The development of palace is carried out on GitHub_.
Since GitHub is not free software, we fully understand
if one does not want to register an account just to participate
in our development. Therefore, we also welcome patches
and bug reports sent via email.
First of all, thank you for using and contributing to palace! We welcome
all forms of contribution, and `the mo the merier`_. By saying this, we also
mean that we much prefer receiving many small and self-contained bug reports,
feature requests and patches than a giant one. There is no limit for
the number of contributions one may or should make. While it may seem
appealing to be able to dump all thoughts and feelings into one ticket,
it would be more difficult for us to keep track of the progress.
Reporting a Bug
---------------
Before filing a bug report, please make sure that the bug has not been
already reported by searching our GitHub Issues_ tracker.
To facilitate the debugging process, a bug report should at least contain
the following information:
#. The platform, the CPython version and the compiler used to build it.
These can be obtained from :py:func:`platform.platform`,
:py:func:`platform.python_version` and :py:func:`platform.python_compiler`,
respectively.
#. The version of palace and how you installed it.
The earlier is usually provided by ``pip show palace``.
#. Detailed instructions on how to reproduce the bug,
for example a short Python script would be appreciated.
Requesting a Feature
--------------------
Prior to filing a feature request, please make sure that the feature
has not been already reported by searching our GitHub Issues_ tracker.
Please only ask for features that you (or an incapacitated friend
you can personally talk to) require. Do not request features because
they seem like a good idea. If they are really useful, they will be
requested by someone who requires them.
Submitting a Patch
------------------
We accept all kinds of patches, from documentation and CI/CD setup
to bug fixes, feature implementations and tests. Except for documentation
located in the ``gh-pages`` branch, others should be filed against
the development branch ``master``. These are hosted on GitHub and
one may create a local repository by running::
git clone https://github.com/McSinyx/palace
While the patch can be submitted via email, it is preferable to file
a pull request on GitHub to allow more people to review it, since we do not
have any mail list. Either way, contributors must have legal permission
to distribute the code and it must be available under `LGPLv3+`_. Furthermore,
each contributor retains the copyrights of their patch, to ensure that
the licence can never be revoked even if others wants to. It is advisable
that the author list per legal name under the copyright header
of each source file they modify, like so::
Copyright (C) 2038 Foo Bar
Using GitHub
^^^^^^^^^^^^
#. Create a fork_ of our repository on GitHub.
#. Checkout the source code and (optionally) add the ``upstream`` remote::
git clone https://github.com/YOUR_GITHUB_USERNAME/palace
cd palace
git remote add upstream https://github.com/McSinyx/palace
#. Start working on your patch and make sure your code complies with
the `Style Guidelines`_ and passes the test suit run by tox_.
#. Add relevant tests to the patch and work on it until they all pass.
In case one is only modifying tests, perse may install palace using
``CYTHON_TRACE=1 pip install .`` then run pytest_ directly to avoid
having to build the extension module multiple times.
#. Update the copyright notices of the files you modified.
Palace is collectively licensed under `LGPLv3+`_,
and to protect the freedom of the users,
copyright holders need to be properly documented.
#. Add_, commit_ with `a great message`_ then push_ the result.
#. Finally, `create a pull request`_. We will then review and merge it.
It is recommended to create a new branch in your fork
(``git checkout -c what-you-are-working-on``) instead of working directly
on ``master``. This way one can still sync per fork with our ``master`` branch
and ``git pull --rebase upstream master`` to avoid integration issues.
Via Email
^^^^^^^^^
#. Checkout the source code::
git clone https://github.com/McSinyx/palace
cd palace
#. Work on your patch with tests and copyright notice included
as described above.
#. `git-format-patch`_ and send it to one of the maintainers
(our emails addresses are available under ``git log``).
We will then review and merge it.
In any case, thank you very much for your contributions!
Making a Release
----------------
While this is meant for developers doing a palace release, contributors wishing
to improve the CI/CD may find it helpful.
#. Under the local repository, checkout the ``master`` branch
and sync with the one on GitHub using ``git pull``.
#. Bump the version in ``setup.cfg`` and push to GitHub.
#. Create a source distribution by running ``setup.py sdist``.
The distribution generated by this command is now referred to as ``sdist``.
#. Using twine_, upload the ``sdist`` to PyPI via ``twine upload $sdist``.
#. On GitHub, tag a new release with the ``sdist`` attached.
In the release note, make sure to include all user-facing changes
since the previous release. This will trigger the CD services
to build the wheels and publish them to PyPI.
#. Wait for the wheel for your platform to arrive to PyPI and install it.
Play around with it for a little to make sure that everything is OK.
#. Under the local repository, checkout the ``gh-pages`` branch.
Often, is it necessary to update the credits under the :doc:`copying`
section and review if the :doc:`reference/index` section needs any change
before running ``make html`` to rebuild to documentation.
#. View the documentation locally then push it to GitHub.
Style Guidelines
----------------
Python and Cython
^^^^^^^^^^^^^^^^^
Generally, palace follows :pep:`8` and :pep:`257`,
with the following preferences and exceptions:
* Hanging indentation is *always* preferred,
where continuation lines are indented by 4 spaces.
* Comments and one-line docstrings are limited to column 79
instead of 72 like for multi-line docstrings.
* Cython extern declarations need not follow the 79-character limit.
* Break long lines before a binary operator.
* Use form feeds sparingly to break long modules
into pages of relating functions and classes.
* Prefer single-quoted strings over double-quoted strings,
unless the string contains single quote characters.
* Avoid trailing commas at all costs.
* Line breaks within comments and docstrings should not cut a phrase in half.
* Everything deserves a docstring. Palace follows numpydoc_ which support
documenting attributes as well as constants and module-level variables.
In additional to docstrings, type annotations should be employed
for all public names.
* Use numpydoc_ markups moderately to keep docstrings readable as plain text.
C++
^^^
C++ codes should follow GNU style, which is best documented at Octave_.
reStructuredText
^^^^^^^^^^^^^^^^
In order for reStructuredText to be rendered correctly, the body of
constructs beginning with a marker (lists, hyperlink targets, comments, etc.)
must be aligned relative to the marker. For this reason, it is convenient
to set your editor indentation level to 3 spaces, since most constructs
starts with two dots and a space. However, be aware of that bullet items
require 2-space alignment and other exceptions.
Limit all lines to a maximum of 79 characters. Similar to comments
and docstrings, phrases should not be broken in the middle.
The source code of this guide itself is a good example on how line breaks
should be handled. Additionally, two spaces should also be used
after a sentence-ending period in multi-sentence paragraph,
except after the final sentence.
.. _GitHub: https://github.com/McSinyx/palace
.. _the mo the merier:
https://www.phrases.org.uk/meanings/the-more-the-merrier.html
.. _Issues: https://github.com/McSinyx/palace/issues
.. _LGPLv3+: https://www.gnu.org/licenses/lgpl-3.0.en.html
.. _fork: https://github.com/McSinyx/palace/fork
.. _tox: https://tox.readthedocs.io/en/latest/
.. _pytest: https://docs.pytest.org/en/latest/
.. _Add: https://git-scm.com/docs/git-add
.. _commit: https://git-scm.com/docs/git-commit
.. _a great message: https://chris.beams.io/posts/git-commit/#seven-rules
.. _push: https://git-scm.com/docs/git-push
.. _create a pull request:
https://help.github.com/articles/creating-a-pull-request
.. _git-format-patch: https://git-scm.com/docs/git-format-patch
.. _twine: https://twine.readthedocs.io/en/latest/
.. _numpydoc: https://numpydoc.readthedocs.io/en/latest/format.html
.. _Octave: https://wiki.octave.org/C%2B%2B_style_guide

View File

@ -1,75 +0,0 @@
Copying
=======
This listing is our best-faith, hard-work effort at accurate attribution,
sources, and licenses for everything in palace. If you discover
an asset/contribution that is incorrectly attributed or licensed,
please contact us immediately. We are happy to do everything we can
to fix or remove the issue.
License
-------
Palace is free software: you can redistribute it and/or modify it
under the terms of the `GNU Lesser General Public License`_
as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
To ensure that palace can run without any dependencies outside of the pip_
toolchain, the wheels are bundled with dynamically linked libraries from
the build machine, which is similar to static linking:
============== ============
Library License
============== ============
Alure_ ZLib
`OpenAL Soft`_ GNU LGPLv2+
Vorbis_ 3-clause BSD
Opus_ 3-clause BSD
libsndfile_ GNU LGPL2.1+
============== ============
In addition, the following sounds are used for testing:
=============================================== =========
Sound (located in ``tests/data``) License
=============================================== =========
`164957__zonkmachine__white-noise.ogg`_ CC0 1.0
`24741__tim-kahn__b23-c1-raw.aiff`_ CC BY 3.0
`261590__kwahmah-02__little-glitch.flac`_ CC BY 3.0
`353684__tec-studio__drip2.mp3`_ CC0 1.0
`99642__jobro__deconvoluted-20hz-to-20khz.wav`_ CC BY 3.0
=============================================== =========
Credits
-------
Palace would never have seen the light of day without the help from
the developers of Alure_ and Cython_ who promptly gave detail answers
and made quick fixes to all of our problems.
The wheels are build using cibuildwheel_, which made building extension modules
much less of a painful experience. `Travis CI`_ and AppVeyor_ kindly provides
their services free of charge for automated CI/CD.
This documentation is generated using Sphinx_, whose maintainer responses
extreamly quickly to obsolete Cython-related issues.
.. _GNU Lesser General Public License:
https://www.gnu.org/licenses/lgpl-3.0.en.html
.. _pip: https://pip.pypa.io/en/latest/
.. _Alure: https://github.com/kcat/alure
.. _OpenAL Soft: https://kcat.strangesoft.net/openal.html
.. _Vorbis: https://xiph.org/vorbis/
.. _Opus: https://opus-codec.org/
.. _libsndfile: http://www.mega-nerd.com/libsndfile/
.. _164957__zonkmachine__white-noise.ogg: https://freesound.org/s/164957/
.. _24741__tim-kahn__b23-c1-raw.aiff: https://freesound.org/s/24741/
.. _261590__kwahmah-02__little-glitch.flac: https://freesound.org/s/261590/
.. _353684__tec-studio__drip2.mp3: https://freesound.org/s/353684/
.. _99642__jobro__deconvoluted-20hz-to-20khz.wav: https://freesound.org/s/99642/
.. _Cython: https://cython.org/
.. _cibuildwheel: https://cibuildwheel.readthedocs.io/en/stable/
.. _Sphinx: https://www.sphinx-doc.org/en/master/
.. _Travis CI: https://travis-ci.com/
.. _AppVeyor: https://www.appveyor.com/

View File

@ -1,185 +0,0 @@
Design Principles
=================
.. currentmodule:: palace
In this section, we will discuss a few design principles in order to write
a safe, efficient, easy-to-use and extendable 3D audio library for Python,
by wrapping existing functionalities from the C++ API alure_.
This part of the documentation assumes its reader are at least familiar with
Cython, Python and C++11.
.. _impl-idiom:
The Impl Idiom
--------------
*Not to be confused with* `the pimpl idiom`_.
For memory-safety, whenever possible, we rely on Cython for allocation and
deallocation of C++ objects. To do this, the nullary constructor needs to be
(re-)declared in Cython, e.g.
.. code-block:: cython
cdef extern from 'foobar.h' namespace 'foobar':
cdef cppclass Foo:
Foo()
float meth(size_t crack) except +
...
The Cython extension type can then be declared as follows
.. code-block:: cython
cdef class Bar:
cdef Foo impl
def __init__(self, *args, **kwargs):
self.impl = ...
@staticmethod
def from_baz(baz: Baz) -> Bar:
bar = Bar.__new__(Bar)
bar.impl = ...
return bar
def meth(self, crack: int) -> float:
return self.impl.meth(crack)
The Modern Python
-----------------
One of the goal of palace is to create a Pythonic, i.e. intuitive and concise,
interface. To achieve this, we try to make use of some modern Python features,
which not only allow users to adopt palace with ease, but also make their
programs more readable and less error-prone.
.. _getter-setter:
Property Attributes
^^^^^^^^^^^^^^^^^^^
A large proportion of alure API are getters/setter methods. In Python,
it is a good practice to use property_ to abstract these calls, and thus make
the interface more natural with attribute-like referencing and assignments.
Due to implementation details, Cython has to hijack the ``@property`` decorator
to make it work for read-write properties. Unfortunately, the Cython-generated
descriptors do not play very well with other builtin decorators, thus in some
cases, it is recommended to alias the call to ``property`` as follows
.. code-block:: python
getter = property
setter = lambda fset: property(fset=fset, doc=fset.__doc__)
Then ``@getter`` and ``@setter`` can be used to decorate read-only and
write-only properties, respectively, without any trouble even if other
decorators are used for the same extension type method.
Context Managers
^^^^^^^^^^^^^^^^
The alure API defines many objects that need manual tear-down in
a particular order. Instead of trying to be clever and perform automatic
clean-ups at garbage collection, we should put the user in control.
To quote *The Zen of Python*,
| If the implementation is hard to explain, it's a bad idea.
| If the implementation is easy to explain, it may be a good idea.
With that being said, it does not mean we do not provide any level of
abstraction. A simplified case in point would be
.. code-block:: cython
cdef class Device:
cdef alure.Device impl
def __init__(self, name: str = '') -> None:
self.impl = devmgr.open_playback(name)
def __enter__(self) -> Device:
return self
def __exit__(self, *exc) -> Optional[bool]:
self.close()
def close(self) -> None:
self.impl.close()
Now if the ``with`` statement is used, it will make sure the device
will be closed, regardless of whatever may happen within the inner block
.. code-block:: python
with Device() as dev:
...
as it is equivalent to
.. code-block:: python
dev = Device()
try:
...
finally:
dev.close()
Other than closure/destruction of objects, typical uses of `context managers`__
also include saving and restoring various kinds of global state (as seen in
:py:class:`Context`), locking and unlocking resources, etc.
__ https://docs.python.org/3/reference/datamodel.html#context-managers
The Double Reference
--------------------
While wrapping C++ interfaces, :ref:`the impl idiom <impl-idiom>` might not
be adequate, since the derived Python methods need to be callable from C++.
Luckily, Cython can handle Python objects within C++ classes just fine,
although we'll need to handle the reference count ourselves, e.g.
.. code-block:: cython
cdef cppclass CppDecoder(alure.BaseDecoder):
Decoder pyo
__init__(Decoder decoder):
this.pyo = decoder
Py_INCREF(pyo)
__dealloc__():
Py_DECREF(pyo)
bool seek(uint64_t pos):
return pyo.seek(pos)
With this being done, we can now write the wrapper as simply as
.. code-block:: cython
cdef class BaseDecoder:
cdef shared_ptr[alure.Decoder] pimpl
def __cinit__(self, *args, **kwargs) -> None:
self.pimpl = shared_ptr[alure.Decoder](new CppDecoder(self))
def seek(pos: int) -> bool:
...
Because ``__cinit__`` is called by ``__new__``, any Python class derived
from ``BaseDecoder`` will be exposed to C++ as an attribute of ``CppDecoder``.
Effectively, this means the users can have the alure API calling their
inherited Python object as naturally as if palace is implemented in pure Python.
In practice, :py:class:`BaseDecoder` will also need to take into account
other guarding mechanisms like :py:class:`abc.ABC`. Due to Cython limitations,
implementation as a pure Python class and :ref:`aliasing <getter-setter>` of
``@getter``/``@setter`` should be considered.
.. _alure: https://github.com/kcat/alure
.. _`the pimpl idiom`: https://wiki.c2.com/?PimplIdiom
.. _property: https://docs.python.org/3/library/functions.html#property

View File

@ -1,38 +0,0 @@
Overview
========
Pythonic Audio Library and Codecs Environment provides common higher-level API
for audio rendering using OpenAL:
* 3D positional rendering, with HRTF_ support for stereo systems
* Environmental effects: reverb, atmospheric air absorption,
sound occlusion and obstruction
* Out-of-the-box codec support: FLAC, MP3, Ogg Vorbis, Opus, WAV, AIFF, etc.
Palace wraps around the C++ interface alure_ using Cython_ for a safe and
convenient interface with type hinting, data descriptors and context managers,
following :pep:`8#naming-conventions` (``PascalCase.snake_case``).
Table of Contents
-----------------
.. toctree::
:maxdepth: 2
installation
tutorial/index
reference/index
design
contributing
copying
Indices and Tables
------------------
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
.. _HRTF: https://en.wikipedia.org/wiki/Head-related_transfer_function
.. _alure: https://github.com/kcat/alure
.. _Cython: https://cython.org

View File

@ -1,37 +0,0 @@
Installation
============
Prerequisites
-------------
Palace requires CPython_ version 3.6 or above for runtime
and pip_ for installation.
Via PyPI
--------
Palace can be installed from PyPI::
pip install palace
Wheel distributions are built exclusively for amd64. Currently, only GNU/Linux
and macOS are properly supported. If you want to help packaging for Windows,
please see `GH-1`_ on our issues tracker on GitHub.
From source
-----------
Aside from the build dependencies listed in ``pyproject.toml``,
one will additionally need compatible Python headers, alure_,
a C++14 compiler, CMake_ 2.6+ (and probably git_ for fetching the source).
Palace can then be compiled and installed by running::
git clone https://github.com/McSinyx/palace.git
pip install palace/
.. _CPython: https://www.python.org/
.. _pip: https://pip.pypa.io/en/latest/
.. _GH-1: https://github.com/McSinyx/palace/issues/1
.. _alure: https://github.com/kcat/alure
.. _CMake: https://cmake.org/
.. _git: https://git-scm.com/

View File

@ -1,17 +0,0 @@
Resource Caching
================
.. currentmodule:: palace
Audio Buffers
-------------
.. autoclass:: Buffer
:members:
Loading & Freeing in Batch
--------------------------
.. autofunction:: cache
.. autofunction:: free

View File

@ -1,83 +0,0 @@
Audio Library Contexts
======================
.. currentmodule:: palace
Context and Auxiliary Classes
-----------------------------
.. autoclass:: Context
:members:
.. autoclass:: Listener
:members:
.. autoclass:: MessageHandler
:members:
Using Contexts
--------------
.. autofunction:: use_context
.. autofunction:: current_context
.. autofunction:: thread_local
Context Creation Attributes
---------------------------
.. data:: CHANNEL_CONFIG
:type: int
Context creation key to specify the channel configuration
(either ``MONO``, ``STEREO``, ``QUAD``, ``X51``, ``X61`` or ``X71``).
.. data:: SAMPLE_TYPE
:type: int
Context creation key to specify the sample type
(either ``[UNSIGNED_]{BYTE,SHORT,INT}`` or ``FLOAT``).
.. data:: FREQUENCY
:type: int
Context creation key to specify the frequency in hertz.
.. data:: MONO_SOURCES
:type: int
Context creation key to specify the number of mono (3D) sources.
.. data:: STEREO_SOURCES
:type: int
Context creation key to specify the number of stereo sources.
.. data:: MAX_AUXILIARY_SENDS
:type: int
Context creation key to specify the maximum number of
auxiliary source sends.
.. data:: HRTF
:type: int
Context creation key to specify whether to enable HRTF
(either ``FALSE``, ``TRUE`` or ``DONT_CARE``).
.. data:: HRTF_ID
:type: int
Context creation key to specify the HRTF to be used.
.. data:: OUTPUT_LIMITER
:type: int
Context creation key to specify whether to use a gain limiter
(either ``FALSE``, ``TRUE`` or ``DONT_CARE``).
.. data:: distance_models
:type: Tuple[str, ...]
Names of available distance models.

View File

@ -1,44 +0,0 @@
Audio Streams
=============
.. currentmodule:: palace
Builtin Decoders
----------------
.. autoclass:: Decoder
:members:
Decoder Interface
-----------------
.. data:: decoder_factories
:type: DecoderNamespace
Simple object for storing decoder factories.
User-registered factories are tried one after another
if :py:exc:`RuntimeError` is raised, in lexicographical order.
Internal decoder factories are always used after registered ones.
.. autofunction:: decode
.. autoclass:: BaseDecoder
:members:
Miscellaneous
-------------
.. data:: sample_types
:type: Tuple[str, ...]
Names of available sample types.
.. data:: channel_configs
:type: Tuple[str, ...]
Names of available channel configurations.
.. autofunction:: sample_size
.. autofunction:: sample_length

View File

@ -1,21 +0,0 @@
Audio Devices
=============
.. currentmodule:: palace
Device-Dependent Utilities
--------------------------
.. autoclass:: Device
:members:
Device-Independent Utilities
----------------------------
.. data:: device_names
:type: DeviceNames
Read-only namespace of device names by category (``basic``, ``full`` and
``capture``), as tuples of strings whose first item being the default.
.. autofunction:: query_extension

View File

@ -1,34 +0,0 @@
Environmental Effects
=====================
.. currentmodule:: palace
For the sake of brevity, we only document the constraints of each effect's
properties. Further details can be found at OpenAL's `Effect Extension Guide`_
which specifies the purpose and usage of each value.
Base Effect
-----------
.. autoclass:: BaseEffect
:members:
Chorus Effect
-------------
.. autoclass:: ChorusEffect
:members:
Reverb Effect
-------------
.. data:: reverb_preset_names
:type: Tuple[str, ...]
Names of predefined reverb effect presets in lexicographical order.
.. autoclass:: ReverbEffect
:members:
.. _Effect Extension Guide:
https://kcat.strangesoft.net/misc-downloads/Effects%20Extension%20Guide.pdf

View File

@ -1,11 +0,0 @@
File I/O Interface
==================
.. currentmodule:: palace
.. autofunction:: current_fileio
.. autofunction:: use_fileio
.. autoclass:: FileIO
:members:

View File

@ -1,14 +0,0 @@
Reference
=========
API reference is divided into the following sections:
.. toctree::
device
context
buffer
source
effect
decoder
file-io

View File

@ -1,16 +0,0 @@
Sources & Source Groups
=======================
.. currentmodule:: palace
Sources
-------
.. autoclass:: Source
:members:
Source Groups
-------------
.. autoclass:: SourceGroup
:members:

View File

@ -1,41 +0,0 @@
Context Creation
================
.. currentmodule:: palace
A context is an object that allows palace to access OpenAL,
which is essential when you work with palace. Context maintains
the audio environment and contains environment settings and components
such as sources, buffers, and effects.
Creating a Device Object
------------------------
To create a context, we must first create a device,
since it's a parameter of the context object.
To create an object, well, you just have to instantiate
the :py:class:`Device` class.
.. code-block:: python
from palace import Device
with Device() as dev:
# Your code goes here
This is how you declare a :py:class:`Device` object with the default device.
There can be several devices available, which can be found
in :py:data:`device_names`.
Creating a Context
------------------
Now that we've created a device, we can create the context:
.. code-block:: python
from palace import Device, Context
with Device() as dev, Context(dev) as ctx:
# Your code goes here

View File

@ -1,15 +0,0 @@
Tutorial
========
This tutorial will guide you on:
.. toctree::
:maxdepth: 2
context
play-audio
source
.. comment these to add later
Adding effects
Customize decoder
Generate sounds

View File

@ -1,101 +0,0 @@
Play an Audio
=============
.. currentmodule:: palace
Now that you know how to create a context,
let's get into the most essential use case: playing audio.
Creating a Source
-----------------
To play an audio, you have to create a source. This source
is an imaginary sound broadcaster, whose positions and properties
can be changed to create desired effects.
.. code-block:: python
from palace import Device, Context, Source
with Device() as dev, Context(dev) as ctx:
with Source() as src:
# to be written
Just like for the case of :py:class:`Context`, :py:class:`Source` creation
requires a context, but here the context is passed implicitly.
Decode the Audio File
---------------------
Palace has a module level function :py:func:`decode`, which decodes audio file
automatically, and this decoded file is a :py:class:`Decoder` object. This object
can be played by a simple :py:meth:`Decoder.play` method.
.. code-block:: python
from palace import Device, Context, Source, decode
filename = 'some_audio.ogg'
with Device() as dev, Context(dev) as ctx:
with Source() as src:
dec = decode(filename)
We are almost there. Now, let's look at the document for :py:meth:`Decoder.play`.
The method takes 3 parameters: ``chunk_len``, ``queue_size``, and ``source``.
The source object is optional, because if you don't have it, a new source
will be generated by default.
The audio is divided into chunks, each of which is of length ``chunk_len``.
Then ``queue_size`` is the number of these chunks that it will play.
.. TODO: I think it's better to include a diagram here. Add later
.. code-block:: python
from palace import Device, Context, Source, decode
filename = 'some_audio.ogg'
with Device() as dev, Context(dev) as ctx:
with Source() as src:
dec = decode(filename)
dec.play(12000, 4, src)
But we don't want it to play only a small part of the audio. We want it to
play all of it. How do we do that? The answer is a loop.
There is a method, :py:meth:`Context.update`, which update the context and the source.
When the source is updated, it will be filled with new chunks of data from
the decoder.
.. code-block:: python
from palace import Device, Context, Source, decode
filename = 'some_audio.ogg'
with Device() as dev, Context(dev) as ctx:
with Source() as src:
dec = decode(filename)
dec.play(12000, 4, src)
while src.playing:
ctx.update()
If you tried this code for a song, you will find that it's a bit rush.
That is because the source is renewed too fast. So, a simple solution
is to ``sleep`` for a while.
.. code-block:: python
from time import sleep
from palace import Device, Context, Source, decode
filename = 'some_audio.ogg'
with Device() as dev, Context(dev) as ctx:
with Source() as src:
dec = decode(filename)
dec.play(12000, 4, src)
while src.playing:
sleep(0.025)
ctx.update()
Congratulation! Enjoy your music before we get to the next part of this tutorial.

View File

@ -1,82 +0,0 @@
Source Manipulation
===================
.. currentmodule:: palace
We have created a source in the last section.
As said previously, its properties can be manipulated to create wanted effects.
Moving the Source
-----------------
Changing :py:attr:`Source.position` is one of the most noticeable,
but first, we have to enable spatialization via :py:attr:`Source.spatialize`.
.. code-block:: python
from time import sleep
from palace import Device, Context, Source, decode
with Device() as device, Context(device) as context, Source() as source:
source.spatialize = True
decoder = decode('some_audio.ogg')
decoder.play(12000, 4, source)
while source.playing:
sleep(0.025)
context.update()
Now, we can set the position of the source in this virtual 3D space.
The position is a 3-tuple indicating the coordinate of the source.
The axes are aligned according to the normal coordinate system:
- The x-axis goes from left to right
- The y-axis goes from below to above
- The z-axis goes from front to back
For example, this will set the source above the listener::
src.position = 0, 1, 0
.. note::
For this too work for stereo, you have to have HRTF enabled.
You can check that via :py:attr:`Device.current_hrtf`.
You can as well use a function to move the source automatically by writing
a function that generate positions. A simple example is circular motion.
.. code-block:: python
from itertools import takewhile, count
...
for i in takewhile(src.playing, count(step=0.025)):
source.position = sin(i), 0, cos(-i)
...
A more well-written example of this can be found `in our repository`_.
Speed and Pitch
---------------
Modifying :py:attr:`pitch` changes the playing speed, effectively changing
pitch. Pitch can be any positive number.
.. code-block:: python
src.pitch = 2 # high pitch
src.pitch = 0.4 # low pitch
Air Absorption Factor
---------------------
:py:attr:`Source.air_absorption_factor` simulates atmospheric high-frequency
air absorption. Higher values simulate foggy air and lower values simulate
drier air.
.. code-block:: python
src.air_absorption_factor = 9 # very high humidity
src.air_absorption_factor = 0 # dry air (default)
.. _in our repository:
https://github.com/McSinyx/palace/blob/master/examples/palace-hrtf.py

View File

@ -1,707 +0,0 @@
@import url("basic.css");
/* -- page layout ----------------------------------------------------------- */
body {
font-family: Georgia, serif;
font-size: 17px;
background-color: #fff;
color: #000;
margin: 0;
padding: 0;
}
div.document {
width: 940px;
margin: 30px auto 0 auto;
}
div.documentwrapper {
float: left;
width: 100%;
}
div.bodywrapper {
margin: 0 0 0 220px;
}
div.sphinxsidebar {
width: 220px;
font-size: 14px;
line-height: 1.5;
}
hr {
border: 1px solid #B1B4B6;
}
div.body {
background-color: #fff;
color: #3E4349;
padding: 0 30px 0 30px;
}
div.body > .section {
text-align: left;
}
div.footer {
width: 940px;
margin: 20px auto 30px auto;
font-size: 14px;
color: #888;
text-align: right;
}
div.footer a {
color: #888;
}
p.caption {
font-family: inherit;
font-size: inherit;
}
div.relations {
display: none;
}
div.sphinxsidebar a {
color: #444;
text-decoration: none;
border-bottom: 1px dotted #999;
}
div.sphinxsidebar a:hover {
border-bottom: 1px solid #999;
}
div.sphinxsidebarwrapper {
padding: 18px 10px;
}
div.sphinxsidebarwrapper p.logo {
padding: 0;
margin: -10px 0 0 0px;
text-align: center;
}
div.sphinxsidebarwrapper h1.logo {
margin-top: -10px;
text-align: center;
margin-bottom: 5px;
text-align: left;
}
div.sphinxsidebarwrapper h1.logo-name {
margin-top: 0px;
}
div.sphinxsidebarwrapper p.blurb {
margin-top: 0;
font-style: normal;
}
div.sphinxsidebar h3,
div.sphinxsidebar h4 {
font-family: Georgia, serif;
color: #444;
font-size: 24px;
font-weight: normal;
margin: 0 0 5px 0;
padding: 0;
}
div.sphinxsidebar h4 {
font-size: 20px;
}
div.sphinxsidebar h3 a {
color: #444;
}
div.sphinxsidebar p.logo a,
div.sphinxsidebar h3 a,
div.sphinxsidebar p.logo a:hover,
div.sphinxsidebar h3 a:hover {
border: none;
}
div.sphinxsidebar p {
color: #555;
margin: 10px 0;
}
div.sphinxsidebar ul {
margin: 10px 0;
padding: 0;
color: #000;
}
div.sphinxsidebar ul li.toctree-l1 > a {
font-size: 120%;
}
div.sphinxsidebar ul li.toctree-l2 > a {
font-size: 110%;
}
div.sphinxsidebar input {
border: 1px solid #CCC;
font-family: Georgia, serif;
font-size: 1em;
}
div.sphinxsidebar hr {
border: none;
height: 1px;
color: #AAA;
background: #AAA;
text-align: left;
margin-left: 0;
width: 50%;
}
div.sphinxsidebar .badge {
border-bottom: none;
}
div.sphinxsidebar .badge:hover {
border-bottom: none;
}
/* To address an issue with donation coming after search */
div.sphinxsidebar h3.donation {
margin-top: 10px;
}
/* -- body styles ----------------------------------------------------------- */
a {
color: #004B6B;
text-decoration: underline;
}
a:hover {
color: #6D4100;
text-decoration: underline;
}
div.body h1,
div.body h2,
div.body h3,
div.body h4,
div.body h5,
div.body h6 {
font-family: Georgia, serif;
font-weight: normal;
margin: 30px 0px 10px 0px;
padding: 0;
}
div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; }
div.body h2 { font-size: 180%; }
div.body h3 { font-size: 150%; }
div.body h4 { font-size: 130%; }
div.body h5 { font-size: 100%; }
div.body h6 { font-size: 100%; }
a.headerlink {
color: #DDD;
padding: 0 4px;
text-decoration: none;
}
a.headerlink:hover {
color: #444;
background: #EAEAEA;
}
div.body p, div.body dd, div.body li {
line-height: 1.4em;
}
div.admonition {
margin: 20px 0px;
padding: 10px 30px;
background-color: #EEE;
border: 1px solid #CCC;
}
div.admonition tt.xref, div.admonition code.xref, div.admonition a tt {
background-color: #FBFBFB;
border-bottom: 1px solid #fafafa;
}
div.admonition p.admonition-title {
font-family: Georgia, serif;
font-weight: normal;
font-size: 24px;
margin: 0 0 10px 0;
padding: 0;
line-height: 1;
}
div.admonition p.last {
margin-bottom: 0;
}
div.highlight {
background-color: #fff;
}
dt:target, .highlight {
background: #FAF3E8;
}
div.warning {
background-color: #FCC;
border: 1px solid #FAA;
}
div.danger {
background-color: #FCC;
border: 1px solid #FAA;
-moz-box-shadow: 2px 2px 4px #D52C2C;
-webkit-box-shadow: 2px 2px 4px #D52C2C;
box-shadow: 2px 2px 4px #D52C2C;
}
div.error {
background-color: #FCC;
border: 1px solid #FAA;
-moz-box-shadow: 2px 2px 4px #D52C2C;
-webkit-box-shadow: 2px 2px 4px #D52C2C;
box-shadow: 2px 2px 4px #D52C2C;
}
div.caution {
background-color: #FCC;
border: 1px solid #FAA;
}
div.attention {
background-color: #FCC;
border: 1px solid #FAA;
}
div.important {
background-color: #EEE;
border: 1px solid #CCC;
}
div.note {
background-color: #EEE;
border: 1px solid #CCC;
}
div.tip {
background-color: #EEE;
border: 1px solid #CCC;
}
div.hint {
background-color: #EEE;
border: 1px solid #CCC;
}
div.seealso {
background-color: #EEE;
border: 1px solid #CCC;
}
div.topic {
background-color: #EEE;
}
p.admonition-title {
display: inline;
}
p.admonition-title:after {
content: ":";
}
pre, tt, code {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
font-size: 0.9em;
}
.hll {
background-color: #FFC;
margin: 0 -12px;
padding: 0 12px;
display: block;
}
img.screenshot {
}
tt.descname, tt.descclassname, code.descname, code.descclassname {
font-size: 0.95em;
}
tt.descname, code.descname {
padding-right: 0.08em;
}
img.screenshot {
-moz-box-shadow: 2px 2px 4px #EEE;
-webkit-box-shadow: 2px 2px 4px #EEE;
box-shadow: 2px 2px 4px #EEE;
}
table.docutils {
border: 1px solid #888;
-moz-box-shadow: 2px 2px 4px #EEE;
-webkit-box-shadow: 2px 2px 4px #EEE;
box-shadow: 2px 2px 4px #EEE;
}
table.docutils td, table.docutils th {
border: 1px solid #888;
padding: 0.25em 0.7em;
}
table.field-list, table.footnote {
border: none;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
table.footnote {
margin: 15px 0;
width: 100%;
border: 1px solid #EEE;
background: #FDFDFD;
font-size: 0.9em;
}
table.footnote + table.footnote {
margin-top: -15px;
border-top: none;
}
table.field-list th {
padding: 0 0.8em 0 0;
}
table.field-list td {
padding: 0;
}
table.field-list p {
margin-bottom: 0.8em;
}
/* Cloned from
* https://github.com/sphinx-doc/sphinx/commit/ef60dbfce09286b20b7385333d63a60321784e68
*/
.field-name {
-moz-hyphens: manual;
-ms-hyphens: manual;
-webkit-hyphens: manual;
hyphens: manual;
}
table.footnote td.label {
width: .1px;
padding: 0.3em 0 0.3em 0.5em;
}
table.footnote td {
padding: 0.3em 0.5em;
}
dl {
margin: 0;
padding: 0;
}
dl dd {
margin-left: 30px;
}
blockquote {
margin: 0 0 0 30px;
padding: 0;
}
ul, ol {
/* Matches the 30px from the narrow-screen "li > ul" selector below */
margin: 10px 0 10px 30px;
padding: 0;
}
pre {
background: #EEE;
padding: 7px 30px;
margin: 15px 0px;
line-height: 1.3em;
}
div.viewcode-block:target {
background: #ffd;
}
dl pre, blockquote pre, li pre {
margin-left: 0;
padding-left: 30px;
}
tt, code {
background-color: #ecf0f3;
color: #222;
/* padding: 1px 2px; */
}
tt.xref, code.xref, a tt {
background-color: #FBFBFB;
border-bottom: 1px solid #fff;
}
a.reference {
text-decoration: none;
border-bottom: 1px dotted #004B6B;
}
/* Don't put an underline on images */
a.image-reference, a.image-reference:hover {
border-bottom: none;
}
a.reference:hover {
border-bottom: 1px solid #6D4100;
}
a.footnote-reference {
text-decoration: none;
font-size: 0.7em;
vertical-align: top;
border-bottom: 1px dotted #004B6B;
}
a.footnote-reference:hover {
border-bottom: 1px solid #6D4100;
}
a:hover tt, a:hover code {
background: #EEE;
}
@media screen and (max-width: 870px) {
div.sphinxsidebar {
display: none;
}
div.document {
width: 100%;
}
div.documentwrapper {
margin-left: 0;
margin-top: 0;
margin-right: 0;
margin-bottom: 0;
}
div.bodywrapper {
margin-top: 0;
margin-right: 0;
margin-bottom: 0;
margin-left: 0;
}
ul {
margin-left: 0;
}
li > ul {
/* Matches the 30px from the "ul, ol" selector above */
margin-left: 30px;
}
.document {
width: auto;
}
.footer {
width: auto;
}
.bodywrapper {
margin: 0;
}
.footer {
width: auto;
}
.github {
display: none;
}
}
@media screen and (max-width: 875px) {
body {
margin: 0;
padding: 20px 30px;
}
div.documentwrapper {
float: none;
background: #fff;
}
div.sphinxsidebar {
display: block;
float: none;
width: 102.5%;
margin: -20px -30px 20px -30px;
padding: 10px 20px;
background: #333;
color: #FFF;
}
div.sphinxsidebar h3, div.sphinxsidebar h4, div.sphinxsidebar p,
div.sphinxsidebar h3 a {
color: #fff;
}
div.sphinxsidebar a {
color: #AAA;
}
div.sphinxsidebar p.logo {
display: none;
}
div.document {
width: 100%;
margin: 0;
}
div.footer {
display: none;
}
div.bodywrapper {
margin: 0;
}
div.body {
min-height: 0;
padding: 0;
}
.rtd_doc_footer {
display: none;
}
.document {
width: auto;
}
.footer {
width: auto;
}
.footer {
width: auto;
}
.github {
display: none;
}
}
@media screen and (min-width: 876px) {
div.sphinxsidebar {
position: fixed;
margin-left: 0;
}
}
/* misc. */
.revsys-inline {
display: none!important;
}
/* Make nested-list/multi-paragraph items look better in Releases changelog
* pages. Without this, docutils' magical list fuckery causes inconsistent
* formatting between different release sub-lists.
*/
div#changelog > div.section > ul > li > p:only-child {
margin-bottom: 0;
}
/* Hide fugly table cell borders in ..bibliography:: directive output */
table.docutils.citation, table.docutils.citation td, table.docutils.citation th {
border: none;
/* Below needed in some edge cases; if not applied, bottom shadows appear */
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
/* relbar */
.related {
line-height: 30px;
width: 100%;
font-size: 0.9rem;
}
.related.top {
border-bottom: 1px solid #EEE;
margin-bottom: 20px;
}
.related.bottom {
border-top: 1px solid #EEE;
}
.related ul {
padding: 0;
margin: 0;
list-style: none;
}
.related li {
display: inline;
}
nav#rellinks {
float: right;
}
nav#rellinks li+li:before {
content: "|";
}
nav#breadcrumbs li+li:before {
content: "\00BB";
}
/* Hide certain items when printing */
@media print {
div.related {
display: none;
}
}

View File

@ -1,855 +0,0 @@
/*
* basic.css
* ~~~~~~~~~
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/* -- main layout ----------------------------------------------------------- */
div.clearer {
clear: both;
}
div.section::after {
display: block;
content: '';
clear: left;
}
/* -- relbar ---------------------------------------------------------------- */
div.related {
width: 100%;
font-size: 90%;
}
div.related h3 {
display: none;
}
div.related ul {
margin: 0;
padding: 0 0 0 10px;
list-style: none;
}
div.related li {
display: inline;
}
div.related li.right {
float: right;
margin-right: 5px;
}
/* -- sidebar --------------------------------------------------------------- */
div.sphinxsidebarwrapper {
padding: 10px 5px 0 10px;
}
div.sphinxsidebar {
float: left;
width: 230px;
margin-left: -100%;
font-size: 90%;
word-wrap: break-word;
overflow-wrap : break-word;
}
div.sphinxsidebar ul {
list-style: none;
}
div.sphinxsidebar ul ul,
div.sphinxsidebar ul.want-points {
margin-left: 20px;
list-style: square;
}
div.sphinxsidebar ul ul {
margin-top: 0;
margin-bottom: 0;
}
div.sphinxsidebar form {
margin-top: 10px;
}
div.sphinxsidebar input {
border: 1px solid #98dbcc;
font-family: sans-serif;
font-size: 1em;
}
div.sphinxsidebar #searchbox form.search {
overflow: hidden;
}
div.sphinxsidebar #searchbox input[type="text"] {
float: left;
width: 80%;
padding: 0.25em;
box-sizing: border-box;
}
div.sphinxsidebar #searchbox input[type="submit"] {
float: left;
width: 20%;
border-left: none;
padding: 0.25em;
box-sizing: border-box;
}
img {
border: 0;
max-width: 100%;
}
/* -- search page ----------------------------------------------------------- */
ul.search {
margin: 10px 0 0 20px;
padding: 0;
}
ul.search li {
padding: 5px 0 5px 20px;
background-image: url(file.png);
background-repeat: no-repeat;
background-position: 0 7px;
}
ul.search li a {
font-weight: bold;
}
ul.search li div.context {
color: #888;
margin: 2px 0 0 30px;
text-align: left;
}
ul.keywordmatches li.goodmatch a {
font-weight: bold;
}
/* -- index page ------------------------------------------------------------ */
table.contentstable {
width: 90%;
margin-left: auto;
margin-right: auto;
}
table.contentstable p.biglink {
line-height: 150%;
}
a.biglink {
font-size: 1.3em;
}
span.linkdescr {
font-style: italic;
padding-top: 5px;
font-size: 90%;
}
/* -- general index --------------------------------------------------------- */
table.indextable {
width: 100%;
}
table.indextable td {
text-align: left;
vertical-align: top;
}
table.indextable ul {
margin-top: 0;
margin-bottom: 0;
list-style-type: none;
}
table.indextable > tbody > tr > td > ul {
padding-left: 0em;
}
table.indextable tr.pcap {
height: 10px;
}
table.indextable tr.cap {
margin-top: 10px;
background-color: #f2f2f2;
}
img.toggler {
margin-right: 3px;
margin-top: 3px;
cursor: pointer;
}
div.modindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
div.genindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
/* -- domain module index --------------------------------------------------- */
table.modindextable td {
padding: 2px;
border-collapse: collapse;
}
/* -- general body styles --------------------------------------------------- */
div.body {
min-width: 450px;
max-width: 800px;
}
div.body p, div.body dd, div.body li, div.body blockquote {
-moz-hyphens: auto;
-ms-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
a.headerlink {
visibility: hidden;
}
a.brackets:before,
span.brackets > a:before{
content: "[";
}
a.brackets:after,
span.brackets > a:after {
content: "]";
}
h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
h4:hover > a.headerlink,
h5:hover > a.headerlink,
h6:hover > a.headerlink,
dt:hover > a.headerlink,
caption:hover > a.headerlink,
p.caption:hover > a.headerlink,
div.code-block-caption:hover > a.headerlink {
visibility: visible;
}
div.body p.caption {
text-align: inherit;
}
div.body td {
text-align: left;
}
.first {
margin-top: 0 !important;
}
p.rubric {
margin-top: 30px;
font-weight: bold;
}
img.align-left, .figure.align-left, object.align-left {
clear: left;
float: left;
margin-right: 1em;
}
img.align-right, .figure.align-right, object.align-right {
clear: right;
float: right;
margin-left: 1em;
}
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
img.align-default, .figure.align-default {
display: block;
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left;
}
.align-center {
text-align: center;
}
.align-default {
text-align: center;
}
.align-right {
text-align: right;
}
/* -- sidebars -------------------------------------------------------------- */
div.sidebar {
margin: 0 0 0.5em 1em;
border: 1px solid #ddb;
padding: 7px;
background-color: #ffe;
width: 40%;
float: right;
clear: right;
overflow-x: auto;
}
p.sidebar-title {
font-weight: bold;
}
div.admonition, div.topic, blockquote {
clear: left;
}
/* -- topics ---------------------------------------------------------------- */
div.topic {
border: 1px solid #ccc;
padding: 7px;
margin: 10px 0 10px 0;
}
p.topic-title {
font-size: 1.1em;
font-weight: bold;
margin-top: 10px;
}
/* -- admonitions ----------------------------------------------------------- */
div.admonition {
margin-top: 10px;
margin-bottom: 10px;
padding: 7px;
}
div.admonition dt {
font-weight: bold;
}
p.admonition-title {
margin: 0px 10px 5px 0px;
font-weight: bold;
}
div.body p.centered {
text-align: center;
margin-top: 25px;
}
/* -- content of sidebars/topics/admonitions -------------------------------- */
div.sidebar > :last-child,
div.topic > :last-child,
div.admonition > :last-child {
margin-bottom: 0;
}
div.sidebar::after,
div.topic::after,
div.admonition::after,
blockquote::after {
display: block;
content: '';
clear: both;
}
/* -- tables ---------------------------------------------------------------- */
table.docutils {
margin-top: 10px;
margin-bottom: 10px;
border: 0;
border-collapse: collapse;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
table.align-default {
margin-left: auto;
margin-right: auto;
}
table caption span.caption-number {
font-style: italic;
}
table caption span.caption-text {
}
table.docutils td, table.docutils th {
padding: 1px 8px 1px 5px;
border-top: 0;
border-left: 0;
border-right: 0;
border-bottom: 1px solid #aaa;
}
table.footnote td, table.footnote th {
border: 0 !important;
}
th {
text-align: left;
padding-right: 5px;
}
table.citation {
border-left: solid 1px gray;
margin-left: 1px;
}
table.citation td {
border-bottom: none;
}
th > :first-child,
td > :first-child {
margin-top: 0px;
}
th > :last-child,
td > :last-child {
margin-bottom: 0px;
}
/* -- figures --------------------------------------------------------------- */
div.figure {
margin: 0.5em;
padding: 0.5em;
}
div.figure p.caption {
padding: 0.3em;
}
div.figure p.caption span.caption-number {
font-style: italic;
}
div.figure p.caption span.caption-text {
}
/* -- field list styles ----------------------------------------------------- */
table.field-list td, table.field-list th {
border: 0 !important;
}
.field-list ul {
margin: 0;
padding-left: 1em;
}
.field-list p {
margin: 0;
}
.field-name {
-moz-hyphens: manual;
-ms-hyphens: manual;
-webkit-hyphens: manual;
hyphens: manual;
}
/* -- hlist styles ---------------------------------------------------------- */
table.hlist {
margin: 1em 0;
}
table.hlist td {
vertical-align: top;
}
/* -- other body styles ----------------------------------------------------- */
ol.arabic {
list-style: decimal;
}
ol.loweralpha {
list-style: lower-alpha;
}
ol.upperalpha {
list-style: upper-alpha;
}
ol.lowerroman {
list-style: lower-roman;
}
ol.upperroman {
list-style: upper-roman;
}
:not(li) > ol > li:first-child > :first-child,
:not(li) > ul > li:first-child > :first-child {
margin-top: 0px;
}
:not(li) > ol > li:last-child > :last-child,
:not(li) > ul > li:last-child > :last-child {
margin-bottom: 0px;
}
ol.simple ol p,
ol.simple ul p,
ul.simple ol p,
ul.simple ul p {
margin-top: 0;
}
ol.simple > li:not(:first-child) > p,
ul.simple > li:not(:first-child) > p {
margin-top: 0;
}
ol.simple p,
ul.simple p {
margin-bottom: 0;
}
dl.footnote > dt,
dl.citation > dt {
float: left;
margin-right: 0.5em;
}
dl.footnote > dd,
dl.citation > dd {
margin-bottom: 0em;
}
dl.footnote > dd:after,
dl.citation > dd:after {
content: "";
clear: both;
}
dl.field-list {
display: grid;
grid-template-columns: fit-content(30%) auto;
}
dl.field-list > dt {
font-weight: bold;
word-break: break-word;
padding-left: 0.5em;
padding-right: 5px;
}
dl.field-list > dt:after {
content: ":";
}
dl.field-list > dd {
padding-left: 0.5em;
margin-top: 0em;
margin-left: 0em;
margin-bottom: 0em;
}
dl {
margin-bottom: 15px;
}
dd > :first-child {
margin-top: 0px;
}
dd ul, dd table {
margin-bottom: 10px;
}
dd {
margin-top: 3px;
margin-bottom: 10px;
margin-left: 30px;
}
dl > dd:last-child,
dl > dd:last-child > :last-child {
margin-bottom: 0;
}
dt:target, span.highlighted {
background-color: #fbe54e;
}
rect.highlighted {
fill: #fbe54e;
}
dl.glossary dt {
font-weight: bold;
font-size: 1.1em;
}
.optional {
font-size: 1.3em;
}
.sig-paren {
font-size: larger;
}
.versionmodified {
font-style: italic;
}
.system-message {
background-color: #fda;
padding: 5px;
border: 3px solid red;
}
.footnote:target {
background-color: #ffa;
}
.line-block {
display: block;
margin-top: 1em;
margin-bottom: 1em;
}
.line-block .line-block {
margin-top: 0;
margin-bottom: 0;
margin-left: 1.5em;
}
.guilabel, .menuselection {
font-family: sans-serif;
}
.accelerator {
text-decoration: underline;
}
.classifier {
font-style: oblique;
}
.classifier:before {
font-style: normal;
margin: 0.5em;
content: ":";
}
abbr, acronym {
border-bottom: dotted 1px;
cursor: help;
}
/* -- code displays --------------------------------------------------------- */
pre {
overflow: auto;
overflow-y: hidden; /* fixes display issues on Chrome browsers */
}
pre, div[class*="highlight-"] {
clear: both;
}
span.pre {
-moz-hyphens: none;
-ms-hyphens: none;
-webkit-hyphens: none;
hyphens: none;
}
div[class*="highlight-"] {
margin: 1em 0;
}
td.linenos pre {
border: 0;
background-color: transparent;
color: #aaa;
}
table.highlighttable {
display: block;
}
table.highlighttable tbody {
display: block;
}
table.highlighttable tr {
display: flex;
}
table.highlighttable td {
margin: 0;
padding: 0;
}
table.highlighttable td.linenos {
padding-right: 0.5em;
}
table.highlighttable td.code {
flex: 1;
overflow: hidden;
}
.highlight .hll {
display: block;
}
div.highlight pre,
table.highlighttable pre {
margin: 0;
}
div.code-block-caption + div {
margin-top: 0;
}
div.code-block-caption {
margin-top: 1em;
padding: 2px 5px;
font-size: small;
}
div.code-block-caption code {
background-color: transparent;
}
table.highlighttable td.linenos,
div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
user-select: none;
}
div.code-block-caption span.caption-number {
padding: 0.1em 0.3em;
font-style: italic;
}
div.code-block-caption span.caption-text {
}
div.literal-block-wrapper {
margin: 1em 0;
}
code.descname {
background-color: transparent;
font-weight: bold;
font-size: 1.2em;
}
code.descclassname {
background-color: transparent;
}
code.xref, a code {
background-color: transparent;
font-weight: bold;
}
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
background-color: transparent;
}
.viewcode-link {
float: right;
}
.viewcode-back {
float: right;
font-family: sans-serif;
}
div.viewcode-block:target {
margin: -1px -10px;
padding: 0 10px;
}
/* -- math display ---------------------------------------------------------- */
img.math {
vertical-align: middle;
}
div.body div.math p {
text-align: center;
}
span.eqno {
float: right;
}
span.eqno a.headerlink {
position: absolute;
z-index: 1;
}
div.math:hover a.headerlink {
visibility: visible;
}
/* -- printout stylesheet --------------------------------------------------- */
@media print {
div.document,
div.documentwrapper,
div.bodywrapper {
margin: 0 !important;
width: 100%;
}
div.sphinxsidebar,
div.related,
div.footer,
#top-link {
display: none;
}
}

View File

@ -1 +0,0 @@
/* This file intentionally left blank. */

View File

@ -1,315 +0,0 @@
/*
* doctools.js
* ~~~~~~~~~~~
*
* Sphinx JavaScript utilities for all documentation.
*
* :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/**
* select a different prefix for underscore
*/
$u = _.noConflict();
/**
* make the code below compatible with browsers without
* an installed firebug like debugger
if (!window.console || !console.firebug) {
var names = ["log", "debug", "info", "warn", "error", "assert", "dir",
"dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace",
"profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {};
}
*/
/**
* small helper function to urldecode strings
*/
jQuery.urldecode = function(x) {
return decodeURIComponent(x).replace(/\+/g, ' ');
};
/**
* small helper function to urlencode strings
*/
jQuery.urlencode = encodeURIComponent;
/**
* This function returns the parsed url parameters of the
* current request. Multiple values per key are supported,
* it will always return arrays of strings for the value parts.
*/
jQuery.getQueryParameters = function(s) {
if (typeof s === 'undefined')
s = document.location.search;
var parts = s.substr(s.indexOf('?') + 1).split('&');
var result = {};
for (var i = 0; i < parts.length; i++) {
var tmp = parts[i].split('=', 2);
var key = jQuery.urldecode(tmp[0]);
var value = jQuery.urldecode(tmp[1]);
if (key in result)
result[key].push(value);
else
result[key] = [value];
}
return result;
};
/**
* highlight a given string on a jquery object by wrapping it in
* span elements with the given class name.
*/
jQuery.fn.highlightText = function(text, className) {
function highlight(node, addItems) {
if (node.nodeType === 3) {
var val = node.nodeValue;
var pos = val.toLowerCase().indexOf(text);
if (pos >= 0 &&
!jQuery(node.parentNode).hasClass(className) &&
!jQuery(node.parentNode).hasClass("nohighlight")) {
var span;
var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg");
if (isInSVG) {
span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
} else {
span = document.createElement("span");
span.className = className;
}
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
document.createTextNode(val.substr(pos + text.length)),
node.nextSibling));
node.nodeValue = val.substr(0, pos);
if (isInSVG) {
var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
var bbox = node.parentElement.getBBox();
rect.x.baseVal.value = bbox.x;
rect.y.baseVal.value = bbox.y;
rect.width.baseVal.value = bbox.width;
rect.height.baseVal.value = bbox.height;
rect.setAttribute('class', className);
addItems.push({
"parent": node.parentNode,
"target": rect});
}
}
}
else if (!jQuery(node).is("button, select, textarea")) {
jQuery.each(node.childNodes, function() {
highlight(this, addItems);
});
}
}
var addItems = [];
var result = this.each(function() {
highlight(this, addItems);
});
for (var i = 0; i < addItems.length; ++i) {
jQuery(addItems[i].parent).before(addItems[i].target);
}
return result;
};
/*
* backward compatibility for jQuery.browser
* This will be supported until firefox bug is fixed.
*/
if (!jQuery.browser) {
jQuery.uaMatch = function(ua) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
/(msie) ([\w.]+)/.exec(ua) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
[];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
jQuery.browser = {};
jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true;
}
/**
* Small JavaScript module for the documentation.
*/
var Documentation = {
init : function() {
this.fixFirefoxAnchorBug();
this.highlightSearchWords();
this.initIndexTable();
if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) {
this.initOnKeyListeners();
}
},
/**
* i18n support
*/
TRANSLATIONS : {},
PLURAL_EXPR : function(n) { return n === 1 ? 0 : 1; },
LOCALE : 'unknown',
// gettext and ngettext don't access this so that the functions
// can safely bound to a different name (_ = Documentation.gettext)
gettext : function(string) {
var translated = Documentation.TRANSLATIONS[string];
if (typeof translated === 'undefined')
return string;
return (typeof translated === 'string') ? translated : translated[0];
},
ngettext : function(singular, plural, n) {
var translated = Documentation.TRANSLATIONS[singular];
if (typeof translated === 'undefined')
return (n == 1) ? singular : plural;
return translated[Documentation.PLURALEXPR(n)];
},
addTranslations : function(catalog) {
for (var key in catalog.messages)
this.TRANSLATIONS[key] = catalog.messages[key];
this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
this.LOCALE = catalog.locale;
},
/**
* add context elements like header anchor links
*/
addContextElements : function() {
$('div[id] > :header:first').each(function() {
$('<a class="headerlink">\u00B6</a>').
attr('href', '#' + this.id).
attr('title', _('Permalink to this headline')).
appendTo(this);
});
$('dt[id]').each(function() {
$('<a class="headerlink">\u00B6</a>').
attr('href', '#' + this.id).
attr('title', _('Permalink to this definition')).
appendTo(this);
});
},
/**
* workaround a firefox stupidity
* see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075
*/
fixFirefoxAnchorBug : function() {
if (document.location.hash && $.browser.mozilla)
window.setTimeout(function() {
document.location.href += '';
}, 10);
},
/**
* highlight the search words provided in the url in the text
*/
highlightSearchWords : function() {
var params = $.getQueryParameters();
var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
if (terms.length) {
var body = $('div.body');
if (!body.length) {
body = $('body');
}
window.setTimeout(function() {
$.each(terms, function() {
body.highlightText(this.toLowerCase(), 'highlighted');
});
}, 10);
$('<p class="highlight-link"><a href="javascript:Documentation.' +
'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')
.appendTo($('#searchbox'));
}
},
/**
* init the domain index toggle buttons
*/
initIndexTable : function() {
var togglers = $('img.toggler').click(function() {
var src = $(this).attr('src');
var idnum = $(this).attr('id').substr(7);
$('tr.cg-' + idnum).toggle();
if (src.substr(-9) === 'minus.png')
$(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
else
$(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
}).css('display', '');
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
togglers.click();
}
},
/**
* helper function to hide the search marks again
*/
hideSearchWords : function() {
$('#searchbox .highlight-link').fadeOut(300);
$('span.highlighted').removeClass('highlighted');
},
/**
* make the url absolute
*/
makeURL : function(relativeURL) {
return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
},
/**
* get the current relative url
*/
getCurrentURL : function() {
var path = document.location.pathname;
var parts = path.split(/\//);
$.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
if (this === '..')
parts.pop();
});
var url = parts.join('/');
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
},
initOnKeyListeners: function() {
$(document).keydown(function(event) {
var activeElementType = document.activeElement.tagName;
// don't navigate when in search box or textarea
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT'
&& !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
switch (event.keyCode) {
case 37: // left
var prevHref = $('link[rel="prev"]').prop('href');
if (prevHref) {
window.location.href = prevHref;
return false;
}
case 39: // right
var nextHref = $('link[rel="next"]').prop('href');
if (nextHref) {
window.location.href = nextHref;
return false;
}
}
}
});
}
};
// quick alias for translations
_ = Documentation.gettext;
$(document).ready(function() {
Documentation.init();
});

View File

@ -1,12 +0,0 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '0.2.1',
LANGUAGE: 'None',
COLLAPSE_INDEX: false,
BUILDER: 'html',
FILE_SUFFIX: '.html',
LINK_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt',
NAVIGATION_WITH_KEYS: false
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 B

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,297 +0,0 @@
/*
* language_data.js
* ~~~~~~~~~~~~~~~~
*
* This script contains the language-specific data used by searchtools.js,
* namely the list of stopwords, stemmer, scorer and splitter.
*
* :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
/* Non-minified version JS is _stemmer.js if file is provided */
/**
* Porter Stemmer
*/
var Stemmer = function() {
var step2list = {
ational: 'ate',
tional: 'tion',
enci: 'ence',
anci: 'ance',
izer: 'ize',
bli: 'ble',
alli: 'al',
entli: 'ent',
eli: 'e',
ousli: 'ous',
ization: 'ize',
ation: 'ate',
ator: 'ate',
alism: 'al',
iveness: 'ive',
fulness: 'ful',
ousness: 'ous',
aliti: 'al',
iviti: 'ive',
biliti: 'ble',
logi: 'log'
};
var step3list = {
icate: 'ic',
ative: '',
alize: 'al',
iciti: 'ic',
ical: 'ic',
ful: '',
ness: ''
};
var c = "[^aeiou]"; // consonant
var v = "[aeiouy]"; // vowel
var C = c + "[^aeiouy]*"; // consonant sequence
var V = v + "[aeiou]*"; // vowel sequence
var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
var s_v = "^(" + C + ")?" + v; // vowel in stem
this.stemWord = function (w) {
var stem;
var suffix;
var firstch;
var origword = w;
if (w.length < 3)
return w;
var re;
var re2;
var re3;
var re4;
firstch = w.substr(0,1);
if (firstch == "y")
w = firstch.toUpperCase() + w.substr(1);
// Step 1a
re = /^(.+?)(ss|i)es$/;
re2 = /^(.+?)([^s])s$/;
if (re.test(w))
w = w.replace(re,"$1$2");
else if (re2.test(w))
w = w.replace(re2,"$1$2");
// Step 1b
re = /^(.+?)eed$/;
re2 = /^(.+?)(ed|ing)$/;
if (re.test(w)) {
var fp = re.exec(w);
re = new RegExp(mgr0);
if (re.test(fp[1])) {
re = /.$/;
w = w.replace(re,"");
}
}
else if (re2.test(w)) {
var fp = re2.exec(w);
stem = fp[1];
re2 = new RegExp(s_v);
if (re2.test(stem)) {
w = stem;
re2 = /(at|bl|iz)$/;
re3 = new RegExp("([^aeiouylsz])\\1$");
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
if (re2.test(w))
w = w + "e";
else if (re3.test(w)) {
re = /.$/;
w = w.replace(re,"");
}
else if (re4.test(w))
w = w + "e";
}
}
// Step 1c
re = /^(.+?)y$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(s_v);
if (re.test(stem))
w = stem + "i";
}
// Step 2
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
suffix = fp[2];
re = new RegExp(mgr0);
if (re.test(stem))
w = stem + step2list[suffix];
}
// Step 3
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
suffix = fp[2];
re = new RegExp(mgr0);
if (re.test(stem))
w = stem + step3list[suffix];
}
// Step 4
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
re2 = /^(.+?)(s|t)(ion)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(mgr1);
if (re.test(stem))
w = stem;
}
else if (re2.test(w)) {
var fp = re2.exec(w);
stem = fp[1] + fp[2];
re2 = new RegExp(mgr1);
if (re2.test(stem))
w = stem;
}
// Step 5
re = /^(.+?)e$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(mgr1);
re2 = new RegExp(meq1);
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
w = stem;
}
re = /ll$/;
re2 = new RegExp(mgr1);
if (re.test(w) && re2.test(w)) {
re = /.$/;
w = w.replace(re,"");
}
// and turn initial Y back to y
if (firstch == "y")
w = firstch.toLowerCase() + w.substr(1);
return w;
}
}
var splitChars = (function() {
var result = {};
var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648,
1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702,
2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971,
2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345,
3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761,
3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823,
4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125,
8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695,
11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587,
43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141];
var i, j, start, end;
for (i = 0; i < singles.length; i++) {
result[singles[i]] = true;
}
var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709],
[722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161],
[1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568],
[1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807],
[1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047],
[2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383],
[2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450],
[2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547],
[2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673],
[2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820],
[2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946],
[2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023],
[3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173],
[3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332],
[3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481],
[3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718],
[3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791],
[3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095],
[4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205],
[4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687],
[4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968],
[4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869],
[5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102],
[6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271],
[6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592],
[6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822],
[6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167],
[7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959],
[7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143],
[8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318],
[8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483],
[8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101],
[10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567],
[11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292],
[12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444],
[12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783],
[12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311],
[19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511],
[42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774],
[42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071],
[43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263],
[43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519],
[43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647],
[43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967],
[44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295],
[57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274],
[64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007],
[65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381],
[65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]];
for (i = 0; i < ranges.length; i++) {
start = ranges[i][0];
end = ranges[i][1];
for (j = start; j <= end; j++) {
result[j] = true;
}
}
return result;
})();
function splitQuery(query) {
var result = [];
var start = -1;
for (var i = 0; i < query.length; i++) {
if (splitChars[query.charCodeAt(i)]) {
if (start !== -1) {
result.push(query.slice(start, i));
start = -1;
}
} else if (start === -1) {
start = i;
}
}
if (start !== -1) {
result.push(query.slice(start));
}
return result;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 B

View File

@ -1,77 +0,0 @@
.highlight .hll { background-color: #ffffcc }
.highlight { background: #f8f8f8; }
.highlight .c { color: #8f5902; font-style: italic } /* Comment */
.highlight .err { color: #a40000; border: 1px solid #ef2929 } /* Error */
.highlight .g { color: #000000 } /* Generic */
.highlight .k { color: #004461; font-weight: bold } /* Keyword */
.highlight .l { color: #000000 } /* Literal */
.highlight .n { color: #000000 } /* Name */
.highlight .o { color: #582800 } /* Operator */
.highlight .x { color: #000000 } /* Other */
.highlight .p { color: #000000; font-weight: bold } /* Punctuation */
.highlight .ch { color: #8f5902; font-style: italic } /* Comment.Hashbang */
.highlight .cm { color: #8f5902; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #8f5902 } /* Comment.Preproc */
.highlight .cpf { color: #8f5902; font-style: italic } /* Comment.PreprocFile */
.highlight .c1 { color: #8f5902; font-style: italic } /* Comment.Single */
.highlight .cs { color: #8f5902; font-style: italic } /* Comment.Special */
.highlight .gd { color: #a40000 } /* Generic.Deleted */
.highlight .ge { color: #000000; font-style: italic } /* Generic.Emph */
.highlight .gr { color: #ef2929 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #745334 } /* Generic.Prompt */
.highlight .gs { color: #000000; font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #a40000; font-weight: bold } /* Generic.Traceback */
.highlight .kc { color: #004461; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #004461; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #004461; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #004461; font-weight: bold } /* Keyword.Pseudo */
.highlight .kr { color: #004461; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #004461; font-weight: bold } /* Keyword.Type */
.highlight .ld { color: #000000 } /* Literal.Date */
.highlight .m { color: #990000 } /* Literal.Number */
.highlight .s { color: #4e9a06 } /* Literal.String */
.highlight .na { color: #c4a000 } /* Name.Attribute */
.highlight .nb { color: #004461 } /* Name.Builtin */
.highlight .nc { color: #000000 } /* Name.Class */
.highlight .no { color: #000000 } /* Name.Constant */
.highlight .nd { color: #888888 } /* Name.Decorator */
.highlight .ni { color: #ce5c00 } /* Name.Entity */
.highlight .ne { color: #cc0000; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #000000 } /* Name.Function */
.highlight .nl { color: #f57900 } /* Name.Label */
.highlight .nn { color: #000000 } /* Name.Namespace */
.highlight .nx { color: #000000 } /* Name.Other */
.highlight .py { color: #000000 } /* Name.Property */
.highlight .nt { color: #004461; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #000000 } /* Name.Variable */
.highlight .ow { color: #004461; font-weight: bold } /* Operator.Word */
.highlight .w { color: #f8f8f8; text-decoration: underline } /* Text.Whitespace */
.highlight .mb { color: #990000 } /* Literal.Number.Bin */
.highlight .mf { color: #990000 } /* Literal.Number.Float */
.highlight .mh { color: #990000 } /* Literal.Number.Hex */
.highlight .mi { color: #990000 } /* Literal.Number.Integer */
.highlight .mo { color: #990000 } /* Literal.Number.Oct */
.highlight .sa { color: #4e9a06 } /* Literal.String.Affix */
.highlight .sb { color: #4e9a06 } /* Literal.String.Backtick */
.highlight .sc { color: #4e9a06 } /* Literal.String.Char */
.highlight .dl { color: #4e9a06 } /* Literal.String.Delimiter */
.highlight .sd { color: #8f5902; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4e9a06 } /* Literal.String.Double */
.highlight .se { color: #4e9a06 } /* Literal.String.Escape */
.highlight .sh { color: #4e9a06 } /* Literal.String.Heredoc */
.highlight .si { color: #4e9a06 } /* Literal.String.Interpol */
.highlight .sx { color: #4e9a06 } /* Literal.String.Other */
.highlight .sr { color: #4e9a06 } /* Literal.String.Regex */
.highlight .s1 { color: #4e9a06 } /* Literal.String.Single */
.highlight .ss { color: #4e9a06 } /* Literal.String.Symbol */
.highlight .bp { color: #3465a4 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #000000 } /* Name.Function.Magic */
.highlight .vc { color: #000000 } /* Name.Variable.Class */
.highlight .vg { color: #000000 } /* Name.Variable.Global */
.highlight .vi { color: #000000 } /* Name.Variable.Instance */
.highlight .vm { color: #000000 } /* Name.Variable.Magic */
.highlight .il { color: #990000 } /* Literal.Number.Integer.Long */

View File

@ -1,514 +0,0 @@
/*
* searchtools.js
* ~~~~~~~~~~~~~~~~
*
* Sphinx JavaScript utilities for the full-text search.
*
* :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
if (!Scorer) {
/**
* Simple result scoring code.
*/
var Scorer = {
// Implement the following function to further tweak the score for each result
// The function takes a result array [filename, title, anchor, descr, score]
// and returns the new score.
/*
score: function(result) {
return result[4];
},
*/
// query matches the full name of an object
objNameMatch: 11,
// or matches in the last dotted part of the object name
objPartialMatch: 6,
// Additive scores depending on the priority of the object
objPrio: {0: 15, // used to be importantResults
1: 5, // used to be objectResults
2: -5}, // used to be unimportantResults
// Used when the priority is not in the mapping.
objPrioDefault: 0,
// query found in title
title: 15,
partialTitle: 7,
// query found in terms
term: 5,
partialTerm: 2
};
}
if (!splitQuery) {
function splitQuery(query) {
return query.split(/\s+/);
}
}
/**
* Search Module
*/
var Search = {
_index : null,
_queued_query : null,
_pulse_status : -1,
htmlToText : function(htmlString) {
var htmlElement = document.createElement('span');
htmlElement.innerHTML = htmlString;
$(htmlElement).find('.headerlink').remove();
docContent = $(htmlElement).find('[role=main]')[0];
if(docContent === undefined) {
console.warn("Content block not found. Sphinx search tries to obtain it " +
"via '[role=main]'. Could you check your theme or template.");
return "";
}
return docContent.textContent || docContent.innerText;
},
init : function() {
var params = $.getQueryParameters();
if (params.q) {
var query = params.q[0];
$('input[name="q"]')[0].value = query;
this.performSearch(query);
}
},
loadIndex : function(url) {
$.ajax({type: "GET", url: url, data: null,
dataType: "script", cache: true,
complete: function(jqxhr, textstatus) {
if (textstatus != "success") {
document.getElementById("searchindexloader").src = url;
}
}});
},
setIndex : function(index) {
var q;
this._index = index;
if ((q = this._queued_query) !== null) {
this._queued_query = null;
Search.query(q);
}
},
hasIndex : function() {
return this._index !== null;
},
deferQuery : function(query) {
this._queued_query = query;
},
stopPulse : function() {
this._pulse_status = 0;
},
startPulse : function() {
if (this._pulse_status >= 0)
return;
function pulse() {
var i;
Search._pulse_status = (Search._pulse_status + 1) % 4;
var dotString = '';
for (i = 0; i < Search._pulse_status; i++)
dotString += '.';
Search.dots.text(dotString);
if (Search._pulse_status > -1)
window.setTimeout(pulse, 500);
}
pulse();
},
/**
* perform a search for something (or wait until index is loaded)
*/
performSearch : function(query) {
// create the required interface elements
this.out = $('#search-results');
this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out);
this.dots = $('<span></span>').appendTo(this.title);
this.status = $('<p class="search-summary">&nbsp;</p>').appendTo(this.out);
this.output = $('<ul class="search"/>').appendTo(this.out);
$('#search-progress').text(_('Preparing search...'));
this.startPulse();
// index already loaded, the browser was quick!
if (this.hasIndex())
this.query(query);
else
this.deferQuery(query);
},
/**
* execute search (requires search index to be loaded)
*/
query : function(query) {
var i;
// stem the searchterms and add them to the correct list
var stemmer = new Stemmer();
var searchterms = [];
var excluded = [];
var hlterms = [];
var tmp = splitQuery(query);
var objectterms = [];
for (i = 0; i < tmp.length; i++) {
if (tmp[i] !== "") {
objectterms.push(tmp[i].toLowerCase());
}
if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i] === "") {
// skip this "word"
continue;
}
// stem the word
var word = stemmer.stemWord(tmp[i].toLowerCase());
// prevent stemmer from cutting word smaller than two chars
if(word.length < 3 && tmp[i].length >= 3) {
word = tmp[i];
}
var toAppend;
// select the correct list
if (word[0] == '-') {
toAppend = excluded;
word = word.substr(1);
}
else {
toAppend = searchterms;
hlterms.push(tmp[i].toLowerCase());
}
// only add if not already in the list
if (!$u.contains(toAppend, word))
toAppend.push(word);
}
var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" "));
// console.debug('SEARCH: searching for:');
// console.info('required: ', searchterms);
// console.info('excluded: ', excluded);
// prepare search
var terms = this._index.terms;
var titleterms = this._index.titleterms;
// array of [filename, title, anchor, descr, score]
var results = [];
$('#search-progress').empty();
// lookup as object
for (i = 0; i < objectterms.length; i++) {
var others = [].concat(objectterms.slice(0, i),
objectterms.slice(i+1, objectterms.length));
results = results.concat(this.performObjectSearch(objectterms[i], others));
}
// lookup as search terms in fulltext
results = results.concat(this.performTermsSearch(searchterms, excluded, terms, titleterms));
// let the scorer override scores with a custom scoring function
if (Scorer.score) {
for (i = 0; i < results.length; i++)
results[i][4] = Scorer.score(results[i]);
}
// now sort the results by score (in opposite order of appearance, since the
// display function below uses pop() to retrieve items) and then
// alphabetically
results.sort(function(a, b) {
var left = a[4];
var right = b[4];
if (left > right) {
return 1;
} else if (left < right) {
return -1;
} else {
// same score: sort alphabetically
left = a[1].toLowerCase();
right = b[1].toLowerCase();
return (left > right) ? -1 : ((left < right) ? 1 : 0);
}
});
// for debugging
//Search.lastresults = results.slice(); // a copy
//console.info('search results:', Search.lastresults);
// print the results
var resultCount = results.length;
function displayNextItem() {
// results left, load the summary and display it
if (results.length) {
var item = results.pop();
var listItem = $('<li style="display:none"></li>');
var requestUrl = "";
var linkUrl = "";
if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') {
// dirhtml builder
var dirname = item[0] + '/';
if (dirname.match(/\/index\/$/)) {
dirname = dirname.substring(0, dirname.length-6);
} else if (dirname == 'index/') {
dirname = '';
}
requestUrl = DOCUMENTATION_OPTIONS.URL_ROOT + dirname;
linkUrl = requestUrl;
} else {
// normal html builders
requestUrl = DOCUMENTATION_OPTIONS.URL_ROOT + item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX;
linkUrl = item[0] + DOCUMENTATION_OPTIONS.LINK_SUFFIX;
}
listItem.append($('<a/>').attr('href',
linkUrl +
highlightstring + item[2]).html(item[1]));
if (item[3]) {
listItem.append($('<span> (' + item[3] + ')</span>'));
Search.output.append(listItem);
listItem.slideDown(5, function() {
displayNextItem();
});
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
$.ajax({url: requestUrl,
dataType: "text",
complete: function(jqxhr, textstatus) {
var data = jqxhr.responseText;
if (data !== '' && data !== undefined) {
listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));
}
Search.output.append(listItem);
listItem.slideDown(5, function() {
displayNextItem();
});
}});
} else {
// no source available, just display title
Search.output.append(listItem);
listItem.slideDown(5, function() {
displayNextItem();
});
}
}
// search finished, update title and status message
else {
Search.stopPulse();
Search.title.text(_('Search Results'));
if (!resultCount)
Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
else
Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount));
Search.status.fadeIn(500);
}
}
displayNextItem();
},
/**
* search for object names
*/
performObjectSearch : function(object, otherterms) {
var filenames = this._index.filenames;
var docnames = this._index.docnames;
var objects = this._index.objects;
var objnames = this._index.objnames;
var titles = this._index.titles;
var i;
var results = [];
for (var prefix in objects) {
for (var name in objects[prefix]) {
var fullname = (prefix ? prefix + '.' : '') + name;
var fullnameLower = fullname.toLowerCase()
if (fullnameLower.indexOf(object) > -1) {
var score = 0;
var parts = fullnameLower.split('.');
// check for different match types: exact matches of full name or
// "last name" (i.e. last dotted part)
if (fullnameLower == object || parts[parts.length - 1] == object) {
score += Scorer.objNameMatch;
// matches in last name
} else if (parts[parts.length - 1].indexOf(object) > -1) {
score += Scorer.objPartialMatch;
}
var match = objects[prefix][name];
var objname = objnames[match[1]][2];
var title = titles[match[0]];
// If more than one term searched for, we require other words to be
// found in the name/title/description
if (otherterms.length > 0) {
var haystack = (prefix + ' ' + name + ' ' +
objname + ' ' + title).toLowerCase();
var allfound = true;
for (i = 0; i < otherterms.length; i++) {
if (haystack.indexOf(otherterms[i]) == -1) {
allfound = false;
break;
}
}
if (!allfound) {
continue;
}
}
var descr = objname + _(', in ') + title;
var anchor = match[3];
if (anchor === '')
anchor = fullname;
else if (anchor == '-')
anchor = objnames[match[1]][1] + '-' + fullname;
// add custom score for some objects according to scorer
if (Scorer.objPrio.hasOwnProperty(match[2])) {
score += Scorer.objPrio[match[2]];
} else {
score += Scorer.objPrioDefault;
}
results.push([docnames[match[0]], fullname, '#'+anchor, descr, score, filenames[match[0]]]);
}
}
}
return results;
},
/**
* search for full-text terms in the index
*/
performTermsSearch : function(searchterms, excluded, terms, titleterms) {
var docnames = this._index.docnames;
var filenames = this._index.filenames;
var titles = this._index.titles;
var i, j, file;
var fileMap = {};
var scoreMap = {};
var results = [];
// perform the search on the required terms
for (i = 0; i < searchterms.length; i++) {
var word = searchterms[i];
var files = [];
var _o = [
{files: terms[word], score: Scorer.term},
{files: titleterms[word], score: Scorer.title}
];
// add support for partial matches
if (word.length > 2) {
for (var w in terms) {
if (w.match(word) && !terms[word]) {
_o.push({files: terms[w], score: Scorer.partialTerm})
}
}
for (var w in titleterms) {
if (w.match(word) && !titleterms[word]) {
_o.push({files: titleterms[w], score: Scorer.partialTitle})
}
}
}
// no match but word was a required one
if ($u.every(_o, function(o){return o.files === undefined;})) {
break;
}
// found search word in contents
$u.each(_o, function(o) {
var _files = o.files;
if (_files === undefined)
return
if (_files.length === undefined)
_files = [_files];
files = files.concat(_files);
// set score for the word in each file to Scorer.term
for (j = 0; j < _files.length; j++) {
file = _files[j];
if (!(file in scoreMap))
scoreMap[file] = {};
scoreMap[file][word] = o.score;
}
});
// create the mapping
for (j = 0; j < files.length; j++) {
file = files[j];
if (file in fileMap && fileMap[file].indexOf(word) === -1)
fileMap[file].push(word);
else
fileMap[file] = [word];
}
}
// now check if the files don't contain excluded terms
for (file in fileMap) {
var valid = true;
// check if all requirements are matched
var filteredTermCount = // as search terms with length < 3 are discarded: ignore
searchterms.filter(function(term){return term.length > 2}).length
if (
fileMap[file].length != searchterms.length &&
fileMap[file].length != filteredTermCount
) continue;
// ensure that none of the excluded terms is in the search result
for (i = 0; i < excluded.length; i++) {
if (terms[excluded[i]] == file ||
titleterms[excluded[i]] == file ||
$u.contains(terms[excluded[i]] || [], file) ||
$u.contains(titleterms[excluded[i]] || [], file)) {
valid = false;
break;
}
}
// if we have still a valid result we can add it to the result list
if (valid) {
// select one (max) score for the file.
// for better ranking, we should calculate ranking by using words statistics like basic tf-idf...
var score = $u.max($u.map(fileMap[file], function(w){return scoreMap[file][w]}));
results.push([docnames[file], titles[file], '', null, score, filenames[file]]);
}
}
return results;
},
/**
* helper function to return a node containing the
* search summary for a given text. keywords is a list
* of stemmed words, hlwords is the list of normal, unstemmed
* words. the first one is used to find the occurrence, the
* latter for highlighting it.
*/
makeSearchSummary : function(htmlText, keywords, hlwords) {
var text = Search.htmlToText(htmlText);
var textLower = text.toLowerCase();
var start = 0;
$.each(keywords, function() {
var i = textLower.indexOf(this.toLowerCase());
if (i > -1)
start = i;
});
start = Math.max(start - 120, 0);
var excerpt = ((start > 0) ? '...' : '') +
$.trim(text.substr(start, 240)) +
((start + 240 - text.length) ? '...' : '');
var rv = $('<div class="context"></div>').text(excerpt);
$.each(hlwords, function() {
rv = rv.highlightText(this, 'highlighted');
});
return rv;
}
};
$(document).ready(function() {
Search.init();
});

View File

@ -1,999 +0,0 @@
// Underscore.js 1.3.1
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore
(function() {
// Baseline setup
// --------------
// Establish the root object, `window` in the browser, or `global` on the server.
var root = this;
// Save the previous value of the `_` variable.
var previousUnderscore = root._;
// Establish the object that gets returned to break out of a loop iteration.
var breaker = {};
// Save bytes in the minified (but not gzipped) version:
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
// Create quick reference variables for speed access to core prototypes.
var slice = ArrayProto.slice,
unshift = ArrayProto.unshift,
toString = ObjProto.toString,
hasOwnProperty = ObjProto.hasOwnProperty;
// All **ECMAScript 5** native function implementations that we hope to use
// are declared here.
var
nativeForEach = ArrayProto.forEach,
nativeMap = ArrayProto.map,
nativeReduce = ArrayProto.reduce,
nativeReduceRight = ArrayProto.reduceRight,
nativeFilter = ArrayProto.filter,
nativeEvery = ArrayProto.every,
nativeSome = ArrayProto.some,
nativeIndexOf = ArrayProto.indexOf,
nativeLastIndexOf = ArrayProto.lastIndexOf,
nativeIsArray = Array.isArray,
nativeKeys = Object.keys,
nativeBind = FuncProto.bind;
// Create a safe reference to the Underscore object for use below.
var _ = function(obj) { return new wrapper(obj); };
// Export the Underscore object for **Node.js**, with
// backwards-compatibility for the old `require()` API. If we're in
// the browser, add `_` as a global object via a string identifier,
// for Closure Compiler "advanced" mode.
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = _;
}
exports._ = _;
} else {
root['_'] = _;
}
// Current version.
_.VERSION = '1.3.1';
// Collection Functions
// --------------------
// The cornerstone, an `each` implementation, aka `forEach`.
// Handles objects with the built-in `forEach`, arrays, and raw objects.
// Delegates to **ECMAScript 5**'s native `forEach` if available.
var each = _.each = _.forEach = function(obj, iterator, context) {
if (obj == null) return;
if (nativeForEach && obj.forEach === nativeForEach) {
obj.forEach(iterator, context);
} else if (obj.length === +obj.length) {
for (var i = 0, l = obj.length; i < l; i++) {
if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;
}
} else {
for (var key in obj) {
if (_.has(obj, key)) {
if (iterator.call(context, obj[key], key, obj) === breaker) return;
}
}
}
};
// Return the results of applying the iterator to each element.
// Delegates to **ECMAScript 5**'s native `map` if available.
_.map = _.collect = function(obj, iterator, context) {
var results = [];
if (obj == null) return results;
if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
each(obj, function(value, index, list) {
results[results.length] = iterator.call(context, value, index, list);
});
if (obj.length === +obj.length) results.length = obj.length;
return results;
};
// **Reduce** builds up a single result from a list of values, aka `inject`,
// or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
_.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
var initial = arguments.length > 2;
if (obj == null) obj = [];
if (nativeReduce && obj.reduce === nativeReduce) {
if (context) iterator = _.bind(iterator, context);
return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
}
each(obj, function(value, index, list) {
if (!initial) {
memo = value;
initial = true;
} else {
memo = iterator.call(context, memo, value, index, list);
}
});
if (!initial) throw new TypeError('Reduce of empty array with no initial value');
return memo;
};
// The right-associative version of reduce, also known as `foldr`.
// Delegates to **ECMAScript 5**'s native `reduceRight` if available.
_.reduceRight = _.foldr = function(obj, iterator, memo, context) {
var initial = arguments.length > 2;
if (obj == null) obj = [];
if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
if (context) iterator = _.bind(iterator, context);
return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
}
var reversed = _.toArray(obj).reverse();
if (context && !initial) iterator = _.bind(iterator, context);
return initial ? _.reduce(reversed, iterator, memo, context) : _.reduce(reversed, iterator);
};
// Return the first value which passes a truth test. Aliased as `detect`.
_.find = _.detect = function(obj, iterator, context) {
var result;
any(obj, function(value, index, list) {
if (iterator.call(context, value, index, list)) {
result = value;
return true;
}
});
return result;
};
// Return all the elements that pass a truth test.
// Delegates to **ECMAScript 5**'s native `filter` if available.
// Aliased as `select`.
_.filter = _.select = function(obj, iterator, context) {
var results = [];
if (obj == null) return results;
if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
each(obj, function(value, index, list) {
if (iterator.call(context, value, index, list)) results[results.length] = value;
});
return results;
};
// Return all the elements for which a truth test fails.
_.reject = function(obj, iterator, context) {
var results = [];
if (obj == null) return results;
each(obj, function(value, index, list) {
if (!iterator.call(context, value, index, list)) results[results.length] = value;
});
return results;
};
// Determine whether all of the elements match a truth test.
// Delegates to **ECMAScript 5**'s native `every` if available.
// Aliased as `all`.
_.every = _.all = function(obj, iterator, context) {
var result = true;
if (obj == null) return result;
if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
each(obj, function(value, index, list) {
if (!(result = result && iterator.call(context, value, index, list))) return breaker;
});
return result;
};
// Determine if at least one element in the object matches a truth test.
// Delegates to **ECMAScript 5**'s native `some` if available.
// Aliased as `any`.
var any = _.some = _.any = function(obj, iterator, context) {
iterator || (iterator = _.identity);
var result = false;
if (obj == null) return result;
if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
each(obj, function(value, index, list) {
if (result || (result = iterator.call(context, value, index, list))) return breaker;
});
return !!result;
};
// Determine if a given value is included in the array or object using `===`.
// Aliased as `contains`.
_.include = _.contains = function(obj, target) {
var found = false;
if (obj == null) return found;
if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
found = any(obj, function(value) {
return value === target;
});
return found;
};
// Invoke a method (with arguments) on every item in a collection.
_.invoke = function(obj, method) {
var args = slice.call(arguments, 2);
return _.map(obj, function(value) {
return (_.isFunction(method) ? method || value : value[method]).apply(value, args);
});
};
// Convenience version of a common use case of `map`: fetching a property.
_.pluck = function(obj, key) {
return _.map(obj, function(value){ return value[key]; });
};
// Return the maximum element or (element-based computation).
_.max = function(obj, iterator, context) {
if (!iterator && _.isArray(obj)) return Math.max.apply(Math, obj);
if (!iterator && _.isEmpty(obj)) return -Infinity;
var result = {computed : -Infinity};
each(obj, function(value, index, list) {
var computed = iterator ? iterator.call(context, value, index, list) : value;
computed >= result.computed && (result = {value : value, computed : computed});
});
return result.value;
};
// Return the minimum element (or element-based computation).
_.min = function(obj, iterator, context) {
if (!iterator && _.isArray(obj)) return Math.min.apply(Math, obj);
if (!iterator && _.isEmpty(obj)) return Infinity;
var result = {computed : Infinity};
each(obj, function(value, index, list) {
var computed = iterator ? iterator.call(context, value, index, list) : value;
computed < result.computed && (result = {value : value, computed : computed});
});
return result.value;
};
// Shuffle an array.
_.shuffle = function(obj) {
var shuffled = [], rand;
each(obj, function(value, index, list) {
if (index == 0) {
shuffled[0] = value;
} else {
rand = Math.floor(Math.random() * (index + 1));
shuffled[index] = shuffled[rand];
shuffled[rand] = value;
}
});
return shuffled;
};
// Sort the object's values by a criterion produced by an iterator.
_.sortBy = function(obj, iterator, context) {
return _.pluck(_.map(obj, function(value, index, list) {
return {
value : value,
criteria : iterator.call(context, value, index, list)
};
}).sort(function(left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0;
}), 'value');
};
// Groups the object's values by a criterion. Pass either a string attribute
// to group by, or a function that returns the criterion.
_.groupBy = function(obj, val) {
var result = {};
var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
each(obj, function(value, index) {
var key = iterator(value, index);
(result[key] || (result[key] = [])).push(value);
});
return result;
};
// Use a comparator function to figure out at what index an object should
// be inserted so as to maintain order. Uses binary search.
_.sortedIndex = function(array, obj, iterator) {
iterator || (iterator = _.identity);
var low = 0, high = array.length;
while (low < high) {
var mid = (low + high) >> 1;
iterator(array[mid]) < iterator(obj) ? low = mid + 1 : high = mid;
}
return low;
};
// Safely convert anything iterable into a real, live array.
_.toArray = function(iterable) {
if (!iterable) return [];
if (iterable.toArray) return iterable.toArray();
if (_.isArray(iterable)) return slice.call(iterable);
if (_.isArguments(iterable)) return slice.call(iterable);
return _.values(iterable);
};
// Return the number of elements in an object.
_.size = function(obj) {
return _.toArray(obj).length;
};
// Array Functions
// ---------------
// Get the first element of an array. Passing **n** will return the first N
// values in the array. Aliased as `head`. The **guard** check allows it to work
// with `_.map`.
_.first = _.head = function(array, n, guard) {
return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
};
// Returns everything but the last entry of the array. Especcialy useful on
// the arguments object. Passing **n** will return all the values in
// the array, excluding the last N. The **guard** check allows it to work with
// `_.map`.
_.initial = function(array, n, guard) {
return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
};
// Get the last element of an array. Passing **n** will return the last N
// values in the array. The **guard** check allows it to work with `_.map`.
_.last = function(array, n, guard) {
if ((n != null) && !guard) {
return slice.call(array, Math.max(array.length - n, 0));
} else {
return array[array.length - 1];
}
};
// Returns everything but the first entry of the array. Aliased as `tail`.
// Especially useful on the arguments object. Passing an **index** will return
// the rest of the values in the array from that index onward. The **guard**
// check allows it to work with `_.map`.
_.rest = _.tail = function(array, index, guard) {
return slice.call(array, (index == null) || guard ? 1 : index);
};
// Trim out all falsy values from an array.
_.compact = function(array) {
return _.filter(array, function(value){ return !!value; });
};
// Return a completely flattened version of an array.
_.flatten = function(array, shallow) {
return _.reduce(array, function(memo, value) {
if (_.isArray(value)) return memo.concat(shallow ? value : _.flatten(value));
memo[memo.length] = value;
return memo;
}, []);
};
// Return a version of the array that does not contain the specified value(s).
_.without = function(array) {
return _.difference(array, slice.call(arguments, 1));
};
// Produce a duplicate-free version of the array. If the array has already
// been sorted, you have the option of using a faster algorithm.
// Aliased as `unique`.
_.uniq = _.unique = function(array, isSorted, iterator) {
var initial = iterator ? _.map(array, iterator) : array;
var result = [];
_.reduce(initial, function(memo, el, i) {
if (0 == i || (isSorted === true ? _.last(memo) != el : !_.include(memo, el))) {
memo[memo.length] = el;
result[result.length] = array[i];
}
return memo;
}, []);
return result;
};
// Produce an array that contains the union: each distinct element from all of
// the passed-in arrays.
_.union = function() {
return _.uniq(_.flatten(arguments, true));
};
// Produce an array that contains every item shared between all the
// passed-in arrays. (Aliased as "intersect" for back-compat.)
_.intersection = _.intersect = function(array) {
var rest = slice.call(arguments, 1);
return _.filter(_.uniq(array), function(item) {
return _.every(rest, function(other) {
return _.indexOf(other, item) >= 0;
});
});
};
// Take the difference between one array and a number of other arrays.
// Only the elements present in just the first array will remain.
_.difference = function(array) {
var rest = _.flatten(slice.call(arguments, 1));
return _.filter(array, function(value){ return !_.include(rest, value); });
};
// Zip together multiple lists into a single array -- elements that share
// an index go together.
_.zip = function() {
var args = slice.call(arguments);
var length = _.max(_.pluck(args, 'length'));
var results = new Array(length);
for (var i = 0; i < length; i++) results[i] = _.pluck(args, "" + i);
return results;
};
// If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
// we need this function. Return the position of the first occurrence of an
// item in an array, or -1 if the item is not included in the array.
// Delegates to **ECMAScript 5**'s native `indexOf` if available.
// If the array is large and already in sort order, pass `true`
// for **isSorted** to use binary search.
_.indexOf = function(array, item, isSorted) {
if (array == null) return -1;
var i, l;
if (isSorted) {
i = _.sortedIndex(array, item);
return array[i] === item ? i : -1;
}
if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
for (i = 0, l = array.length; i < l; i++) if (i in array && array[i] === item) return i;
return -1;
};
// Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
_.lastIndexOf = function(array, item) {
if (array == null) return -1;
if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) return array.lastIndexOf(item);
var i = array.length;
while (i--) if (i in array && array[i] === item) return i;
return -1;
};
// Generate an integer Array containing an arithmetic progression. A port of
// the native Python `range()` function. See
// [the Python documentation](http://docs.python.org/library/functions.html#range).
_.range = function(start, stop, step) {
if (arguments.length <= 1) {
stop = start || 0;
start = 0;
}
step = arguments[2] || 1;
var len = Math.max(Math.ceil((stop - start) / step), 0);
var idx = 0;
var range = new Array(len);
while(idx < len) {
range[idx++] = start;
start += step;
}
return range;
};
// Function (ahem) Functions
// ------------------
// Reusable constructor function for prototype setting.
var ctor = function(){};
// Create a function bound to a given object (assigning `this`, and arguments,
// optionally). Binding with arguments is also known as `curry`.
// Delegates to **ECMAScript 5**'s native `Function.bind` if available.
// We check for `func.bind` first, to fail fast when `func` is undefined.
_.bind = function bind(func, context) {
var bound, args;
if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
if (!_.isFunction(func)) throw new TypeError;
args = slice.call(arguments, 2);
return bound = function() {
if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
ctor.prototype = func.prototype;
var self = new ctor;
var result = func.apply(self, args.concat(slice.call(arguments)));
if (Object(result) === result) return result;
return self;
};
};
// Bind all of an object's methods to that object. Useful for ensuring that
// all callbacks defined on an object belong to it.
_.bindAll = function(obj) {
var funcs = slice.call(arguments, 1);
if (funcs.length == 0) funcs = _.functions(obj);
each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
return obj;
};
// Memoize an expensive function by storing its results.
_.memoize = function(func, hasher) {
var memo = {};
hasher || (hasher = _.identity);
return function() {
var key = hasher.apply(this, arguments);
return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
};
};
// Delays a function for the given number of milliseconds, and then calls
// it with the arguments supplied.
_.delay = function(func, wait) {
var args = slice.call(arguments, 2);
return setTimeout(function(){ return func.apply(func, args); }, wait);
};
// Defers a function, scheduling it to run after the current call stack has
// cleared.
_.defer = function(func) {
return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
};
// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time.
_.throttle = function(func, wait) {
var context, args, timeout, throttling, more;
var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
return function() {
context = this; args = arguments;
var later = function() {
timeout = null;
if (more) func.apply(context, args);
whenDone();
};
if (!timeout) timeout = setTimeout(later, wait);
if (throttling) {
more = true;
} else {
func.apply(context, args);
}
whenDone();
throttling = true;
};
};
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds.
_.debounce = function(func, wait) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
func.apply(context, args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
};
// Returns a function that will be executed at most one time, no matter how
// often you call it. Useful for lazy initialization.
_.once = function(func) {
var ran = false, memo;
return function() {
if (ran) return memo;
ran = true;
return memo = func.apply(this, arguments);
};
};
// Returns the first function passed as an argument to the second,
// allowing you to adjust arguments, run code before and after, and
// conditionally execute the original function.
_.wrap = function(func, wrapper) {
return function() {
var args = [func].concat(slice.call(arguments, 0));
return wrapper.apply(this, args);
};
};
// Returns a function that is the composition of a list of functions, each
// consuming the return value of the function that follows.
_.compose = function() {
var funcs = arguments;
return function() {
var args = arguments;
for (var i = funcs.length - 1; i >= 0; i--) {
args = [funcs[i].apply(this, args)];
}
return args[0];
};
};
// Returns a function that will only be executed after being called N times.
_.after = function(times, func) {
if (times <= 0) return func();
return function() {
if (--times < 1) { return func.apply(this, arguments); }
};
};
// Object Functions
// ----------------
// Retrieve the names of an object's properties.
// Delegates to **ECMAScript 5**'s native `Object.keys`
_.keys = nativeKeys || function(obj) {
if (obj !== Object(obj)) throw new TypeError('Invalid object');
var keys = [];
for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
return keys;
};
// Retrieve the values of an object's properties.
_.values = function(obj) {
return _.map(obj, _.identity);
};
// Return a sorted list of the function names available on the object.
// Aliased as `methods`
_.functions = _.methods = function(obj) {
var names = [];
for (var key in obj) {
if (_.isFunction(obj[key])) names.push(key);
}
return names.sort();
};
// Extend a given object with all the properties in passed-in object(s).
_.extend = function(obj) {
each(slice.call(arguments, 1), function(source) {
for (var prop in source) {
obj[prop] = source[prop];
}
});
return obj;
};
// Fill in a given object with default properties.
_.defaults = function(obj) {
each(slice.call(arguments, 1), function(source) {
for (var prop in source) {
if (obj[prop] == null) obj[prop] = source[prop];
}
});
return obj;
};
// Create a (shallow-cloned) duplicate of an object.
_.clone = function(obj) {
if (!_.isObject(obj)) return obj;
return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
};
// Invokes interceptor with the obj, and then returns obj.
// The primary purpose of this method is to "tap into" a method chain, in
// order to perform operations on intermediate results within the chain.
_.tap = function(obj, interceptor) {
interceptor(obj);
return obj;
};
// Internal recursive comparison function.
function eq(a, b, stack) {
// Identical objects are equal. `0 === -0`, but they aren't identical.
// See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
if (a === b) return a !== 0 || 1 / a == 1 / b;
// A strict comparison is necessary because `null == undefined`.
if (a == null || b == null) return a === b;
// Unwrap any wrapped objects.
if (a._chain) a = a._wrapped;
if (b._chain) b = b._wrapped;
// Invoke a custom `isEqual` method if one is provided.
if (a.isEqual && _.isFunction(a.isEqual)) return a.isEqual(b);
if (b.isEqual && _.isFunction(b.isEqual)) return b.isEqual(a);
// Compare `[[Class]]` names.
var className = toString.call(a);
if (className != toString.call(b)) return false;
switch (className) {
// Strings, numbers, dates, and booleans are compared by value.
case '[object String]':
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
// equivalent to `new String("5")`.
return a == String(b);
case '[object Number]':
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
// other numeric values.
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
case '[object Date]':
case '[object Boolean]':
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
// millisecond representations. Note that invalid dates with millisecond representations
// of `NaN` are not equivalent.
return +a == +b;
// RegExps are compared by their source patterns and flags.
case '[object RegExp]':
return a.source == b.source &&
a.global == b.global &&
a.multiline == b.multiline &&
a.ignoreCase == b.ignoreCase;
}
if (typeof a != 'object' || typeof b != 'object') return false;
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
var length = stack.length;
while (length--) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
if (stack[length] == a) return true;
}
// Add the first object to the stack of traversed objects.
stack.push(a);
var size = 0, result = true;
// Recursively compare objects and arrays.
if (className == '[object Array]') {
// Compare array lengths to determine if a deep comparison is necessary.
size = a.length;
result = size == b.length;
if (result) {
// Deep compare the contents, ignoring non-numeric properties.
while (size--) {
// Ensure commutative equality for sparse arrays.
if (!(result = size in a == size in b && eq(a[size], b[size], stack))) break;
}
}
} else {
// Objects with different constructors are not equivalent.
if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) return false;
// Deep compare objects.
for (var key in a) {
if (_.has(a, key)) {
// Count the expected number of properties.
size++;
// Deep compare each member.
if (!(result = _.has(b, key) && eq(a[key], b[key], stack))) break;
}
}
// Ensure that both objects contain the same number of properties.
if (result) {
for (key in b) {
if (_.has(b, key) && !(size--)) break;
}
result = !size;
}
}
// Remove the first object from the stack of traversed objects.
stack.pop();
return result;
}
// Perform a deep comparison to check if two objects are equal.
_.isEqual = function(a, b) {
return eq(a, b, []);
};
// Is a given array, string, or object empty?
// An "empty" object has no enumerable own-properties.
_.isEmpty = function(obj) {
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
for (var key in obj) if (_.has(obj, key)) return false;
return true;
};
// Is a given value a DOM element?
_.isElement = function(obj) {
return !!(obj && obj.nodeType == 1);
};
// Is a given value an array?
// Delegates to ECMA5's native Array.isArray
_.isArray = nativeIsArray || function(obj) {
return toString.call(obj) == '[object Array]';
};
// Is a given variable an object?
_.isObject = function(obj) {
return obj === Object(obj);
};
// Is a given variable an arguments object?
_.isArguments = function(obj) {
return toString.call(obj) == '[object Arguments]';
};
if (!_.isArguments(arguments)) {
_.isArguments = function(obj) {
return !!(obj && _.has(obj, 'callee'));
};
}
// Is a given value a function?
_.isFunction = function(obj) {
return toString.call(obj) == '[object Function]';
};
// Is a given value a string?
_.isString = function(obj) {
return toString.call(obj) == '[object String]';
};
// Is a given value a number?
_.isNumber = function(obj) {
return toString.call(obj) == '[object Number]';
};
// Is the given value `NaN`?
_.isNaN = function(obj) {
// `NaN` is the only value for which `===` is not reflexive.
return obj !== obj;
};
// Is a given value a boolean?
_.isBoolean = function(obj) {
return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
};
// Is a given value a date?
_.isDate = function(obj) {
return toString.call(obj) == '[object Date]';
};
// Is the given value a regular expression?
_.isRegExp = function(obj) {
return toString.call(obj) == '[object RegExp]';
};
// Is a given value equal to null?
_.isNull = function(obj) {
return obj === null;
};
// Is a given variable undefined?
_.isUndefined = function(obj) {
return obj === void 0;
};
// Has own property?
_.has = function(obj, key) {
return hasOwnProperty.call(obj, key);
};
// Utility Functions
// -----------------
// Run Underscore.js in *noConflict* mode, returning the `_` variable to its
// previous owner. Returns a reference to the Underscore object.
_.noConflict = function() {
root._ = previousUnderscore;
return this;
};
// Keep the identity function around for default iterators.
_.identity = function(value) {
return value;
};
// Run a function **n** times.
_.times = function (n, iterator, context) {
for (var i = 0; i < n; i++) iterator.call(context, i);
};
// Escape a string for HTML interpolation.
_.escape = function(string) {
return (''+string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
};
// Add your own custom functions to the Underscore object, ensuring that
// they're correctly added to the OOP wrapper as well.
_.mixin = function(obj) {
each(_.functions(obj), function(name){
addToWrapper(name, _[name] = obj[name]);
});
};
// Generate a unique integer id (unique within the entire client session).
// Useful for temporary DOM ids.
var idCounter = 0;
_.uniqueId = function(prefix) {
var id = idCounter++;
return prefix ? prefix + id : id;
};
// By default, Underscore uses ERB-style template delimiters, change the
// following template settings to use alternative delimiters.
_.templateSettings = {
evaluate : /<%([\s\S]+?)%>/g,
interpolate : /<%=([\s\S]+?)%>/g,
escape : /<%-([\s\S]+?)%>/g
};
// When customizing `templateSettings`, if you don't want to define an
// interpolation, evaluation or escaping regex, we need one that is
// guaranteed not to match.
var noMatch = /.^/;
// Within an interpolation, evaluation, or escaping, remove HTML escaping
// that had been previously added.
var unescape = function(code) {
return code.replace(/\\\\/g, '\\').replace(/\\'/g, "'");
};
// JavaScript micro-templating, similar to John Resig's implementation.
// Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code.
_.template = function(str, data) {
var c = _.templateSettings;
var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
'with(obj||{}){__p.push(\'' +
str.replace(/\\/g, '\\\\')
.replace(/'/g, "\\'")
.replace(c.escape || noMatch, function(match, code) {
return "',_.escape(" + unescape(code) + "),'";
})
.replace(c.interpolate || noMatch, function(match, code) {
return "'," + unescape(code) + ",'";
})
.replace(c.evaluate || noMatch, function(match, code) {
return "');" + unescape(code).replace(/[\r\n\t]/g, ' ') + ";__p.push('";
})
.replace(/\r/g, '\\r')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
+ "');}return __p.join('');";
var func = new Function('obj', '_', tmpl);
if (data) return func(data, _);
return function(data) {
return func.call(this, data, _);
};
};
// Add a "chain" function, which will delegate to the wrapper.
_.chain = function(obj) {
return _(obj).chain();
};
// The OOP Wrapper
// ---------------
// If Underscore is called as a function, it returns a wrapped object that
// can be used OO-style. This wrapper holds altered versions of all the
// underscore functions. Wrapped objects may be chained.
var wrapper = function(obj) { this._wrapped = obj; };
// Expose `wrapper.prototype` as `_.prototype`
_.prototype = wrapper.prototype;
// Helper function to continue chaining intermediate results.
var result = function(obj, chain) {
return chain ? _(obj).chain() : obj;
};
// A method to easily add functions to the OOP wrapper.
var addToWrapper = function(name, func) {
wrapper.prototype[name] = function() {
var args = slice.call(arguments);
unshift.call(args, this._wrapped);
return result(func.apply(_, args), this._chain);
};
};
// Add all of the Underscore functions to the wrapper object.
_.mixin(_);
// Add all mutator Array functions to the wrapper.
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
var method = ArrayProto[name];
wrapper.prototype[name] = function() {
var wrapped = this._wrapped;
method.apply(wrapped, arguments);
var length = wrapped.length;
if ((name == 'shift' || name == 'splice') && length === 0) delete wrapped[0];
return result(wrapped, this._chain);
};
});
// Add all accessor Array functions to the wrapper.
each(['concat', 'join', 'slice'], function(name) {
var method = ArrayProto[name];
wrapper.prototype[name] = function() {
return result(method.apply(this._wrapped, arguments), this._chain);
};
});
// Start chaining a wrapped Underscore object.
wrapper.prototype.chain = function() {
this._chain = true;
return this;
};
// Extracts the result from a wrapped and chained object.
wrapper.prototype.value = function() {
return this._wrapped;
};
}).call(this);

View File

@ -1,31 +0,0 @@
// Underscore.js 1.3.1
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore
(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,
h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each=
b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===n)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===n)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(x&&a.map===x)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==
null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=
function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e=
e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&(e={value:a,computed:b})});
return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){f==0?b[0]=a:(d=Math.floor(Math.random()*(f+1)),b[f]=b[d],b[d]=a)});return b};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,g){return{value:a,criteria:c.call(d,a,b,g)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,
c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:a.toArray?a.toArray():b.isArray(a)?i.call(a):b.isArguments(a)?i.call(a):b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=
b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,e=[];b.reduce(d,function(d,g,h){if(0==h||(c===true?b.last(d)!=g:!b.include(d,g)))d[d.length]=g,e[e.length]=a[h];return d},[]);
return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,
d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(p&&a.indexOf===p)return a.indexOf(c);for(d=0,e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(D&&a.lastIndexOf===D)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g};
var F=function(){};b.bind=function(a,c){var d,e;if(a.bind===s&&s)return s.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));F.prototype=a.prototype;var b=new F,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,
c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i=b.debounce(function(){h=g=false},c);return function(){d=this;e=arguments;var b;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);i()},c));g?h=true:
a.apply(d,e);i();g=true}};b.debounce=function(a,b){var d;return function(){var e=this,f=arguments;clearTimeout(d);d=setTimeout(function(){d=null;a.apply(e,f)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};
b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments,
1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};
b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};
b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.mixin=function(a){j(b.functions(a),
function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+
u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]=
function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=
true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);

View File

@ -1,332 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Getting Involved &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Copying" href="copying.html" />
<link rel="prev" title="Design Principles" href="design.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="design.html">Design Principles</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Getting Involved</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#reporting-a-bug">Reporting a Bug</a></li>
<li class="toctree-l2"><a class="reference internal" href="#requesting-a-feature">Requesting a Feature</a></li>
<li class="toctree-l2"><a class="reference internal" href="#submitting-a-patch">Submitting a Patch</a></li>
<li class="toctree-l2"><a class="reference internal" href="#making-a-release">Making a Release</a></li>
<li class="toctree-l2"><a class="reference internal" href="#style-guidelines">Style Guidelines</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="design.html" title="Previous document">Design Principles</a>
</li>
<li>
<a href="copying.html" title="Next document">Copying</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="getting-involved">
<h1>Getting Involved<a class="headerlink" href="#getting-involved" title="Permalink to this headline"></a></h1>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The development of palace is carried out on <a class="reference external" href="https://github.com/McSinyx/palace">GitHub</a>.
Since GitHub is not free software, we fully understand
if one does not want to register an account just to participate
in our development. Therefore, we also welcome patches
and bug reports sent via email.</p>
</div>
<p>First of all, thank you for using and contributing to palace! We welcome
all forms of contribution, and <a class="reference external" href="https://www.phrases.org.uk/meanings/the-more-the-merrier.html">the mo the merier</a>. By saying this, we also
mean that we much prefer receiving many small and self-contained bug reports,
feature requests and patches than a giant one. There is no limit for
the number of contributions one may or should make. While it may seem
appealing to be able to dump all thoughts and feelings into one ticket,
it would be more difficult for us to keep track of the progress.</p>
<div class="section" id="reporting-a-bug">
<h2>Reporting a Bug<a class="headerlink" href="#reporting-a-bug" title="Permalink to this headline"></a></h2>
<p>Before filing a bug report, please make sure that the bug has not been
already reported by searching our GitHub <a class="reference external" href="https://github.com/McSinyx/palace/issues">Issues</a> tracker.</p>
<p>To facilitate the debugging process, a bug report should at least contain
the following information:</p>
<ol class="arabic simple">
<li><p>The platform, the CPython version and the compiler used to build it.
These can be obtained from <code class="xref py py-func docutils literal notranslate"><span class="pre">platform.platform()</span></code>,
<code class="xref py py-func docutils literal notranslate"><span class="pre">platform.python_version()</span></code> and <code class="xref py py-func docutils literal notranslate"><span class="pre">platform.python_compiler()</span></code>,
respectively.</p></li>
<li><p>The version of palace and how you installed it.
The earlier is usually provided by <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">show</span> <span class="pre">palace</span></code>.</p></li>
<li><p>Detailed instructions on how to reproduce the bug,
for example a short Python script would be appreciated.</p></li>
</ol>
</div>
<div class="section" id="requesting-a-feature">
<h2>Requesting a Feature<a class="headerlink" href="#requesting-a-feature" title="Permalink to this headline"></a></h2>
<p>Prior to filing a feature request, please make sure that the feature
has not been already reported by searching our GitHub <a class="reference external" href="https://github.com/McSinyx/palace/issues">Issues</a> tracker.</p>
<p>Please only ask for features that you (or an incapacitated friend
you can personally talk to) require. Do not request features because
they seem like a good idea. If they are really useful, they will be
requested by someone who requires them.</p>
</div>
<div class="section" id="submitting-a-patch">
<h2>Submitting a Patch<a class="headerlink" href="#submitting-a-patch" title="Permalink to this headline"></a></h2>
<p>We accept all kinds of patches, from documentation and CI/CD setup
to bug fixes, feature implementations and tests. Except for documentation
located in the <code class="docutils literal notranslate"><span class="pre">gh-pages</span></code> branch, others should be filed against
the development branch <code class="docutils literal notranslate"><span class="pre">master</span></code>. These are hosted on GitHub and
one may create a local repository by running:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">McSinyx</span><span class="o">/</span><span class="n">palace</span>
</pre></div>
</div>
<p>While the patch can be submitted via email, it is preferable to file
a pull request on GitHub to allow more people to review it, since we do not
have any mail list. Either way, contributors must have legal permission
to distribute the code and it must be available under <a class="reference external" href="https://www.gnu.org/licenses/lgpl-3.0.en.html">LGPLv3+</a>. Furthermore,
each contributor retains the copyrights of their patch, to ensure that
the licence can never be revoked even if others wants to. It is advisable
that the author list per legal name under the copyright header
of each source file they modify, like so:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Copyright</span> <span class="p">(</span><span class="n">C</span><span class="p">)</span> <span class="mi">2038</span> <span class="n">Foo</span> <span class="n">Bar</span>
</pre></div>
</div>
<div class="section" id="using-github">
<h3>Using GitHub<a class="headerlink" href="#using-github" title="Permalink to this headline"></a></h3>
<ol class="arabic">
<li><p>Create a <a class="reference external" href="https://github.com/McSinyx/palace/fork">fork</a> of our repository on GitHub.</p></li>
<li><p>Checkout the source code and (optionally) add the <code class="docutils literal notranslate"><span class="pre">upstream</span></code> remote:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">YOUR_GITHUB_USERNAME</span><span class="o">/</span><span class="n">palace</span>
<span class="n">cd</span> <span class="n">palace</span>
<span class="n">git</span> <span class="n">remote</span> <span class="n">add</span> <span class="n">upstream</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">McSinyx</span><span class="o">/</span><span class="n">palace</span>
</pre></div>
</div>
</li>
<li><p>Start working on your patch and make sure your code complies with
the <a class="reference internal" href="#style-guidelines">Style Guidelines</a> and passes the test suit run by <a class="reference external" href="https://tox.readthedocs.io/en/latest/">tox</a>.</p></li>
<li><p>Add relevant tests to the patch and work on it until they all pass.
In case one is only modifying tests, perse may install palace using
<code class="docutils literal notranslate"><span class="pre">CYTHON_TRACE=1</span> <span class="pre">pip</span> <span class="pre">install</span> <span class="pre">.</span></code> then run <a class="reference external" href="https://docs.pytest.org/en/latest/">pytest</a> directly to avoid
having to build the extension module multiple times.</p></li>
<li><p>Update the copyright notices of the files you modified.
Palace is collectively licensed under <a class="reference external" href="https://www.gnu.org/licenses/lgpl-3.0.en.html">LGPLv3+</a>,
and to protect the freedom of the users,
copyright holders need to be properly documented.</p></li>
<li><p><a class="reference external" href="https://git-scm.com/docs/git-add">Add</a>, <a class="reference external" href="https://git-scm.com/docs/git-commit">commit</a> with <a class="reference external" href="https://chris.beams.io/posts/git-commit/#seven-rules">a great message</a> then <a class="reference external" href="https://git-scm.com/docs/git-push">push</a> the result.</p></li>
<li><p>Finally, <a class="reference external" href="https://help.github.com/articles/creating-a-pull-request">create a pull request</a>. We will then review and merge it.</p></li>
</ol>
<p>It is recommended to create a new branch in your fork
(<code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">checkout</span> <span class="pre">-c</span> <span class="pre">what-you-are-working-on</span></code>) instead of working directly
on <code class="docutils literal notranslate"><span class="pre">master</span></code>. This way one can still sync per fork with our <code class="docutils literal notranslate"><span class="pre">master</span></code> branch
and <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">pull</span> <span class="pre">--rebase</span> <span class="pre">upstream</span> <span class="pre">master</span></code> to avoid integration issues.</p>
</div>
<div class="section" id="via-email">
<h3>Via Email<a class="headerlink" href="#via-email" title="Permalink to this headline"></a></h3>
<ol class="arabic">
<li><p>Checkout the source code:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">McSinyx</span><span class="o">/</span><span class="n">palace</span>
<span class="n">cd</span> <span class="n">palace</span>
</pre></div>
</div>
</li>
<li><p>Work on your patch with tests and copyright notice included
as described above.</p></li>
<li><p><a class="reference external" href="https://git-scm.com/docs/git-format-patch">git-format-patch</a> and send it to one of the maintainers
(our emails addresses are available under <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">log</span></code>).
We will then review and merge it.</p></li>
</ol>
<p>In any case, thank you very much for your contributions!</p>
</div>
</div>
<div class="section" id="making-a-release">
<h2>Making a Release<a class="headerlink" href="#making-a-release" title="Permalink to this headline"></a></h2>
<p>While this is meant for developers doing a palace release, contributors wishing
to improve the CI/CD may find it helpful.</p>
<ol class="arabic simple">
<li><p>Under the local repository, checkout the <code class="docutils literal notranslate"><span class="pre">master</span></code> branch
and sync with the one on GitHub using <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">pull</span></code>.</p></li>
<li><p>Bump the version in <code class="docutils literal notranslate"><span class="pre">setup.cfg</span></code> and push to GitHub.</p></li>
<li><p>Create a source distribution by running <code class="docutils literal notranslate"><span class="pre">setup.py</span> <span class="pre">sdist</span></code>.
The distribution generated by this command is now referred to as <code class="docutils literal notranslate"><span class="pre">sdist</span></code>.</p></li>
<li><p>Using <a class="reference external" href="https://twine.readthedocs.io/en/latest/">twine</a>, upload the <code class="docutils literal notranslate"><span class="pre">sdist</span></code> to PyPI via <code class="docutils literal notranslate"><span class="pre">twine</span> <span class="pre">upload</span> <span class="pre">$sdist</span></code>.</p></li>
<li><p>On GitHub, tag a new release with the <code class="docutils literal notranslate"><span class="pre">sdist</span></code> attached.
In the release note, make sure to include all user-facing changes
since the previous release. This will trigger the CD services
to build the wheels and publish them to PyPI.</p></li>
<li><p>Wait for the wheel for your platform to arrive to PyPI and install it.
Play around with it for a little to make sure that everything is OK.</p></li>
<li><p>Under the local repository, checkout the <code class="docutils literal notranslate"><span class="pre">gh-pages</span></code> branch.
Often, is it necessary to update the credits under the <a class="reference internal" href="copying.html"><span class="doc">Copying</span></a>
section and review if the <a class="reference internal" href="reference/index.html"><span class="doc">Reference</span></a> section needs any change
before running <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">html</span></code> to rebuild to documentation.</p></li>
<li><p>View the documentation locally then push it to GitHub.</p></li>
</ol>
</div>
<div class="section" id="style-guidelines">
<h2>Style Guidelines<a class="headerlink" href="#style-guidelines" title="Permalink to this headline"></a></h2>
<div class="section" id="python-and-cython">
<h3>Python and Cython<a class="headerlink" href="#python-and-cython" title="Permalink to this headline"></a></h3>
<p>Generally, palace follows <span class="target" id="index-0"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0008"><strong>PEP 8</strong></a> and <span class="target" id="index-1"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0257"><strong>PEP 257</strong></a>,
with the following preferences and exceptions:</p>
<ul class="simple">
<li><p>Hanging indentation is <em>always</em> preferred,
where continuation lines are indented by 4 spaces.</p></li>
<li><p>Comments and one-line docstrings are limited to column 79
instead of 72 like for multi-line docstrings.</p></li>
<li><p>Cython extern declarations need not follow the 79-character limit.</p></li>
<li><p>Break long lines before a binary operator.</p></li>
<li><p>Use form feeds sparingly to break long modules
into pages of relating functions and classes.</p></li>
<li><p>Prefer single-quoted strings over double-quoted strings,
unless the string contains single quote characters.</p></li>
<li><p>Avoid trailing commas at all costs.</p></li>
<li><p>Line breaks within comments and docstrings should not cut a phrase in half.</p></li>
<li><p>Everything deserves a docstring. Palace follows <a class="reference external" href="https://numpydoc.readthedocs.io/en/latest/format.html">numpydoc</a> which support
documenting attributes as well as constants and module-level variables.
In additional to docstrings, type annotations should be employed
for all public names.</p></li>
<li><p>Use <a class="reference external" href="https://numpydoc.readthedocs.io/en/latest/format.html">numpydoc</a> markups moderately to keep docstrings readable as plain text.</p></li>
</ul>
</div>
<div class="section" id="c">
<h3>C++<a class="headerlink" href="#c" title="Permalink to this headline"></a></h3>
<p>C++ codes should follow GNU style, which is best documented at <a class="reference external" href="https://wiki.octave.org/C%2B%2B_style_guide">Octave</a>.</p>
</div>
<div class="section" id="restructuredtext">
<h3>reStructuredText<a class="headerlink" href="#restructuredtext" title="Permalink to this headline"></a></h3>
<p>In order for reStructuredText to be rendered correctly, the body of
constructs beginning with a marker (lists, hyperlink targets, comments, etc.)
must be aligned relative to the marker. For this reason, it is convenient
to set your editor indentation level to 3 spaces, since most constructs
starts with two dots and a space. However, be aware of that bullet items
require 2-space alignment and other exceptions.</p>
<p>Limit all lines to a maximum of 79 characters. Similar to comments
and docstrings, phrases should not be broken in the middle.
The source code of this guide itself is a good example on how line breaks
should be handled. Additionally, two spaces should also be used
after a sentence-ending period in multi-sentence paragraph,
except after the final sentence.</p>
</div>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="design.html" title="Previous document">Design Principles</a>
</li>
<li>
<a href="copying.html" title="Next document">Copying</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/contributing.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,224 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Copying &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="Getting Involved" href="contributing.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Getting Involved</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Copying</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#license">License</a></li>
<li class="toctree-l2"><a class="reference internal" href="#credits">Credits</a></li>
</ul>
</li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="contributing.html" title="Previous document">Getting Involved</a>
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="copying">
<h1>Copying<a class="headerlink" href="#copying" title="Permalink to this headline"></a></h1>
<p>This listing is our best-faith, hard-work effort at accurate attribution,
sources, and licenses for everything in palace. If you discover
an asset/contribution that is incorrectly attributed or licensed,
please contact us immediately. We are happy to do everything we can
to fix or remove the issue.</p>
<div class="section" id="license">
<h2>License<a class="headerlink" href="#license" title="Permalink to this headline"></a></h2>
<p>Palace is free software: you can redistribute it and/or modify it
under the terms of the <a class="reference external" href="https://www.gnu.org/licenses/lgpl-3.0.en.html">GNU Lesser General Public License</a>
as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.</p>
<p>To ensure that palace can run without any dependencies outside of the <a class="reference external" href="https://pip.pypa.io/en/latest/">pip</a>
toolchain, the wheels are bundled with dynamically linked libraries from
the build machine, which is similar to static linking:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 54%" />
<col style="width: 46%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Library</p></th>
<th class="head"><p>License</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><a class="reference external" href="https://github.com/kcat/alure">Alure</a></p></td>
<td><p>ZLib</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference external" href="https://kcat.strangesoft.net/openal.html">OpenAL Soft</a></p></td>
<td><p>GNU LGPLv2+</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference external" href="https://xiph.org/vorbis/">Vorbis</a></p></td>
<td><p>3-clause BSD</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference external" href="https://opus-codec.org/">Opus</a></p></td>
<td><p>3-clause BSD</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference external" href="http://www.mega-nerd.com/libsndfile/">libsndfile</a></p></td>
<td><p>GNU LGPL2.1+</p></td>
</tr>
</tbody>
</table>
<p>In addition, the following sounds are used for testing:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 84%" />
<col style="width: 16%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Sound (located in <code class="docutils literal notranslate"><span class="pre">tests/data</span></code>)</p></th>
<th class="head"><p>License</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><a class="reference external" href="https://freesound.org/s/164957/">164957__zonkmachine__white-noise.ogg</a></p></td>
<td><p>CC0 1.0</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference external" href="https://freesound.org/s/24741/">24741__tim-kahn__b23-c1-raw.aiff</a></p></td>
<td><p>CC BY 3.0</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference external" href="https://freesound.org/s/261590/">261590__kwahmah-02__little-glitch.flac</a></p></td>
<td><p>CC BY 3.0</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference external" href="https://freesound.org/s/353684/">353684__tec-studio__drip2.mp3</a></p></td>
<td><p>CC0 1.0</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference external" href="https://freesound.org/s/99642/">99642__jobro__deconvoluted-20hz-to-20khz.wav</a></p></td>
<td><p>CC BY 3.0</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="credits">
<h2>Credits<a class="headerlink" href="#credits" title="Permalink to this headline"></a></h2>
<p>Palace would never have seen the light of day without the help from
the developers of <a class="reference external" href="https://github.com/kcat/alure">Alure</a> and <a class="reference external" href="https://cython.org/">Cython</a> who promptly gave detail answers
and made quick fixes to all of our problems.</p>
<p>The wheels are build using <a class="reference external" href="https://cibuildwheel.readthedocs.io/en/stable/">cibuildwheel</a>, which made building extension modules
much less of a painful experience. <a class="reference external" href="https://travis-ci.com/">Travis CI</a> and <a class="reference external" href="https://www.appveyor.com/">AppVeyor</a> kindly provides
their services free of charge for automated CI/CD.</p>
<p>This documentation is generated using <a class="reference external" href="https://www.sphinx-doc.org/en/master/">Sphinx</a>, whose maintainer responses
extreamly quickly to obsolete Cython-related issues.</p>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="contributing.html" title="Previous document">Getting Involved</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/copying.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,299 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Design Principles &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Getting Involved" href="contributing.html" />
<link rel="prev" title="File I/O Interface" href="reference/file-io.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Design Principles</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#the-impl-idiom">The Impl Idiom</a></li>
<li class="toctree-l2"><a class="reference internal" href="#the-modern-python">The Modern Python</a></li>
<li class="toctree-l2"><a class="reference internal" href="#the-double-reference">The Double Reference</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="reference/file-io.html" title="Previous document">File I/O Interface</a>
</li>
<li>
<a href="contributing.html" title="Next document">Getting Involved</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="design-principles">
<h1>Design Principles<a class="headerlink" href="#design-principles" title="Permalink to this headline"></a></h1>
<p>In this section, we will discuss a few design principles in order to write
a safe, efficient, easy-to-use and extendable 3D audio library for Python,
by wrapping existing functionalities from the C++ API <a class="reference external" href="https://github.com/kcat/alure">alure</a>.</p>
<p>This part of the documentation assumes its reader are at least familiar with
Cython, Python and C++11.</p>
<div class="section" id="the-impl-idiom">
<span id="impl-idiom"></span><h2>The Impl Idiom<a class="headerlink" href="#the-impl-idiom" title="Permalink to this headline"></a></h2>
<p><em>Not to be confused with</em> <a class="reference external" href="https://wiki.c2.com/?PimplIdiom">the pimpl idiom</a>.</p>
<p>For memory-safety, whenever possible, we rely on Cython for allocation and
deallocation of C++ objects. To do this, the nullary constructor needs to be
(re-)declared in Cython, e.g.</p>
<div class="highlight-cython notranslate"><div class="highlight"><pre><span></span><span class="k">cdef</span> <span class="kr">extern</span> <span class="k">from</span> <span class="s">&#39;foobar.h&#39;</span> <span class="n">namespace</span> <span class="s">&#39;foobar&#39;</span><span class="p">:</span>
<span class="k">cdef</span> <span class="kt">cppclass</span> <span class="nf">Foo</span><span class="p">:</span>
<span class="n">Foo</span><span class="p">()</span>
<span class="nb">float</span> <span class="n">meth</span><span class="p">(</span><span class="n">size_t</span> <span class="n">crack</span><span class="p">)</span> <span class="k">except</span> <span class="o">+</span>
<span class="o">...</span>
</pre></div>
</div>
<p>The Cython extension type can then be declared as follows</p>
<div class="highlight-cython notranslate"><div class="highlight"><pre><span></span><span class="k">cdef</span> <span class="k">class</span> <span class="nf">Bar</span><span class="p">:</span>
<span class="k">cdef</span> <span class="kt">Foo</span> <span class="nf">impl</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">impl</span> <span class="o">=</span> <span class="o">...</span>
<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">from_baz</span><span class="p">(</span><span class="n">baz</span><span class="p">:</span> <span class="n">Baz</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Bar</span><span class="p">:</span>
<span class="n">bar</span> <span class="o">=</span> <span class="n">Bar</span><span class="o">.</span><span class="n">__new__</span><span class="p">(</span><span class="n">Bar</span><span class="p">)</span>
<span class="n">bar</span><span class="o">.</span><span class="n">impl</span> <span class="o">=</span> <span class="o">...</span>
<span class="k">return</span> <span class="n">bar</span>
<span class="k">def</span> <span class="nf">meth</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">crack</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">float</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">impl</span><span class="o">.</span><span class="n">meth</span><span class="p">(</span><span class="n">crack</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="the-modern-python">
<h2>The Modern Python<a class="headerlink" href="#the-modern-python" title="Permalink to this headline"></a></h2>
<p>One of the goal of palace is to create a Pythonic, i.e. intuitive and concise,
interface. To achieve this, we try to make use of some modern Python features,
which not only allow users to adopt palace with ease, but also make their
programs more readable and less error-prone.</p>
<div class="section" id="property-attributes">
<span id="getter-setter"></span><h3>Property Attributes<a class="headerlink" href="#property-attributes" title="Permalink to this headline"></a></h3>
<p>A large proportion of alure API are getters/setter methods. In Python,
it is a good practice to use <a class="reference external" href="https://docs.python.org/3/library/functions.html#property">property</a> to abstract these calls, and thus make
the interface more natural with attribute-like referencing and assignments.</p>
<p>Due to implementation details, Cython has to hijack the <code class="docutils literal notranslate"><span class="pre">&#64;property</span></code> decorator
to make it work for read-write properties. Unfortunately, the Cython-generated
descriptors do not play very well with other builtin decorators, thus in some
cases, it is recommended to alias the call to <code class="docutils literal notranslate"><span class="pre">property</span></code> as follows</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">getter</span> <span class="o">=</span> <span class="nb">property</span>
<span class="n">setter</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">fset</span><span class="p">:</span> <span class="nb">property</span><span class="p">(</span><span class="n">fset</span><span class="o">=</span><span class="n">fset</span><span class="p">,</span> <span class="n">doc</span><span class="o">=</span><span class="n">fset</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">)</span>
</pre></div>
</div>
<p>Then <code class="docutils literal notranslate"><span class="pre">&#64;getter</span></code> and <code class="docutils literal notranslate"><span class="pre">&#64;setter</span></code> can be used to decorate read-only and
write-only properties, respectively, without any trouble even if other
decorators are used for the same extension type method.</p>
</div>
<div class="section" id="context-managers">
<h3>Context Managers<a class="headerlink" href="#context-managers" title="Permalink to this headline"></a></h3>
<p>The alure API defines many objects that need manual tear-down in
a particular order. Instead of trying to be clever and perform automatic
clean-ups at garbage collection, we should put the user in control.
To quote <em>The Zen of Python</em>,</p>
<blockquote>
<div><div class="line-block">
<div class="line">If the implementation is hard to explain, its a bad idea.</div>
<div class="line">If the implementation is easy to explain, it may be a good idea.</div>
</div>
</div></blockquote>
<p>With that being said, it does not mean we do not provide any level of
abstraction. A simplified case in point would be</p>
<div class="highlight-cython notranslate"><div class="highlight"><pre><span></span><span class="k">cdef</span> <span class="k">class</span> <span class="nf">Device</span><span class="p">:</span>
<span class="k">cdef</span> <span class="kt">alure</span>.<span class="kt">Device</span> <span class="nf">impl</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s">&#39;&#39;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">impl</span> <span class="o">=</span> <span class="n">devmgr</span><span class="o">.</span><span class="n">open_playback</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Device</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span>
<span class="k">def</span> <span class="nf">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">exc</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">impl</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
<p>Now if the <code class="docutils literal notranslate"><span class="pre">with</span></code> statement is used, it will make sure the device
will be closed, regardless of whatever may happen within the inner block</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="n">Device</span><span class="p">()</span> <span class="k">as</span> <span class="n">dev</span><span class="p">:</span>
<span class="o">...</span>
</pre></div>
</div>
<p>as it is equivalent to</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">dev</span> <span class="o">=</span> <span class="n">Device</span><span class="p">()</span>
<span class="k">try</span><span class="p">:</span>
<span class="o">...</span>
<span class="k">finally</span><span class="p">:</span>
<span class="n">dev</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
<p>Other than closure/destruction of objects, typical uses of <a class="reference external" href="https://docs.python.org/3/reference/datamodel.html#context-managers">context managers</a>
also include saving and restoring various kinds of global state (as seen in
<a class="reference internal" href="reference/context.html#palace.Context" title="palace.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context</span></code></a>), locking and unlocking resources, etc.</p>
</div>
</div>
<div class="section" id="the-double-reference">
<h2>The Double Reference<a class="headerlink" href="#the-double-reference" title="Permalink to this headline"></a></h2>
<p>While wrapping C++ interfaces, <a class="reference internal" href="#impl-idiom"><span class="std std-ref">the impl idiom</span></a> might not
be adequate, since the derived Python methods need to be callable from C++.
Luckily, Cython can handle Python objects within C++ classes just fine,
although well need to handle the reference count ourselves, e.g.</p>
<div class="highlight-cython notranslate"><div class="highlight"><pre><span></span><span class="k">cdef</span> <span class="kt">cppclass</span> <span class="nf">CppDecoder</span><span class="p">(</span><span class="n">alure</span><span class="o">.</span><span class="n">BaseDecoder</span><span class="p">):</span>
<span class="n">Decoder</span> <span class="n">pyo</span>
<span class="n">__init__</span><span class="p">(</span><span class="n">Decoder</span> <span class="n">decoder</span><span class="p">):</span>
<span class="n">this</span><span class="o">.</span><span class="n">pyo</span> <span class="o">=</span> <span class="n">decoder</span>
<span class="n">Py_INCREF</span><span class="p">(</span><span class="n">pyo</span><span class="p">)</span>
<span class="n">__dealloc__</span><span class="p">():</span>
<span class="n">Py_DECREF</span><span class="p">(</span><span class="n">pyo</span><span class="p">)</span>
<span class="nb">bool</span> <span class="n">seek</span><span class="p">(</span><span class="n">uint64_t</span> <span class="n">pos</span><span class="p">):</span>
<span class="k">return</span> <span class="n">pyo</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="n">pos</span><span class="p">)</span>
</pre></div>
</div>
<p>With this being done, we can now write the wrapper as simply as</p>
<div class="highlight-cython notranslate"><div class="highlight"><pre><span></span><span class="k">cdef</span> <span class="k">class</span> <span class="nf">BaseDecoder</span><span class="p">:</span>
<span class="k">cdef</span> <span class="kt">shared_ptr</span>[<span class="kt">alure</span>.<span class="kt">Decoder</span>] <span class="nf">pimpl</span>
<span class="k">def</span> <span class="nf">__cinit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">pimpl</span> <span class="o">=</span> <span class="n">shared_ptr</span><span class="p">[</span><span class="n">alure</span><span class="o">.</span><span class="n">Decoder</span><span class="p">](</span><span class="n">new</span> <span class="n">CppDecoder</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
<span class="k">def</span> <span class="nf">seek</span><span class="p">(</span><span class="n">pos</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="o">...</span>
</pre></div>
</div>
<p>Because <code class="docutils literal notranslate"><span class="pre">__cinit__</span></code> is called by <code class="docutils literal notranslate"><span class="pre">__new__</span></code>, any Python class derived
from <code class="docutils literal notranslate"><span class="pre">BaseDecoder</span></code> will be exposed to C++ as an attribute of <code class="docutils literal notranslate"><span class="pre">CppDecoder</span></code>.
Effectively, this means the users can have the alure API calling their
inherited Python object as naturally as if palace is implemented in pure Python.</p>
<p>In practice, <a class="reference internal" href="reference/decoder.html#palace.BaseDecoder" title="palace.BaseDecoder"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseDecoder</span></code></a> will also need to take into account
other guarding mechanisms like <code class="xref py py-class docutils literal notranslate"><span class="pre">abc.ABC</span></code>. Due to Cython limitations,
implementation as a pure Python class and <a class="reference internal" href="#getter-setter"><span class="std std-ref">aliasing</span></a> of
<code class="docutils literal notranslate"><span class="pre">&#64;getter</span></code>/<code class="docutils literal notranslate"><span class="pre">&#64;setter</span></code> should be considered.</p>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="reference/file-io.html" title="Previous document">File I/O Interface</a>
</li>
<li>
<a href="contributing.html" title="Next document">Getting Involved</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/design.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,722 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<link rel="index" title="Index" href="#" />
<link rel="search" title="Search" href="search.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
</ul>
</nav>
</div>
<div class="body" role="main">
<h1 id="index">Index</h1>
<div class="genindex-jumpbox">
<a href="#A"><strong>A</strong></a>
| <a href="#B"><strong>B</strong></a>
| <a href="#C"><strong>C</strong></a>
| <a href="#D"><strong>D</strong></a>
| <a href="#E"><strong>E</strong></a>
| <a href="#F"><strong>F</strong></a>
| <a href="#G"><strong>G</strong></a>
| <a href="#H"><strong>H</strong></a>
| <a href="#I"><strong>I</strong></a>
| <a href="#L"><strong>L</strong></a>
| <a href="#M"><strong>M</strong></a>
| <a href="#N"><strong>N</strong></a>
| <a href="#O"><strong>O</strong></a>
| <a href="#P"><strong>P</strong></a>
| <a href="#Q"><strong>Q</strong></a>
| <a href="#R"><strong>R</strong></a>
| <a href="#S"><strong>S</strong></a>
| <a href="#T"><strong>T</strong></a>
| <a href="#U"><strong>U</strong></a>
| <a href="#V"><strong>V</strong></a>
| <a href="#W"><strong>W</strong></a>
</div>
<h2 id="A">A</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/source.html#palace.Source.air_absorption_factor">air_absorption_factor (palace.Source attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.air_absorption_gain_hf">air_absorption_gain_hf (palace.ReverbEffect attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/device.html#palace.Device.alc_version">alc_version() (palace.Device property)</a>
</li>
<li><a href="reference/context.html#palace.Context.async_wake_interval">async_wake_interval (palace.Context attribute)</a>
</li>
<li><a href="reference/context.html#palace.Context.available_resamplers">available_resamplers() (palace.Context property)</a>
</li>
</ul></td>
</tr></table>
<h2 id="B">B</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/decoder.html#palace.BaseDecoder">BaseDecoder (class in palace)</a>
</li>
<li><a href="reference/effect.html#palace.BaseEffect">BaseEffect (class in palace)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/device.html#palace.Device.basic_name">basic_name() (palace.Device property)</a>
</li>
<li><a href="reference/buffer.html#palace.Buffer">Buffer (class in palace)</a>
</li>
<li><a href="reference/context.html#palace.MessageHandler.buffer_loading">buffer_loading() (palace.MessageHandler method)</a>
</li>
</ul></td>
</tr></table>
<h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/buffer.html#palace.cache">cache() (in module palace)</a>
</li>
<li><a href="reference/context.html#palace.CHANNEL_CONFIG">CHANNEL_CONFIG (in module palace)</a>
</li>
<li><a href="reference/decoder.html#palace.BaseDecoder.channel_config">channel_config() (palace.BaseDecoder property)</a>
<ul>
<li><a href="reference/buffer.html#palace.Buffer.channel_config">(palace.Buffer property)</a>
</li>
<li><a href="reference/decoder.html#palace.Decoder.channel_config">(palace.Decoder property)</a>
</li>
</ul></li>
<li><a href="reference/decoder.html#palace.channel_configs">channel_configs (in module palace)</a>
</li>
<li><a href="reference/effect.html#palace.ChorusEffect">ChorusEffect (class in palace)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/device.html#palace.Device.clock_time">clock_time() (palace.Device property)</a>
</li>
<li><a href="reference/device.html#palace.Device.close">close() (palace.Device method)</a>
<ul>
<li><a href="reference/file-io.html#palace.FileIO.close">(palace.FileIO method)</a>
</li>
</ul></li>
<li><a href="reference/source.html#palace.Source.cone_angles">cone_angles (palace.Source attribute)</a>
</li>
<li><a href="reference/context.html#palace.Context">Context (class in palace)</a>
</li>
<li><a href="reference/context.html#palace.current_context">current_context() (in module palace)</a>
</li>
<li><a href="reference/file-io.html#palace.current_fileio">current_fileio() (in module palace)</a>
</li>
<li><a href="reference/device.html#palace.Device.current_hrtf">current_hrtf() (palace.Device property)</a>
</li>
</ul></td>
</tr></table>
<h2 id="D">D</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/effect.html#palace.ReverbEffect.decay_hf_limit">decay_hf_limit (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.decay_hf_ratio">decay_hf_ratio (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.decay_lf_ratio">decay_lf_ratio (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.decay_time">decay_time (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/decoder.html#palace.decode">decode() (in module palace)</a>
</li>
<li><a href="reference/decoder.html#palace.Decoder">Decoder (class in palace)</a>
</li>
<li><a href="reference/decoder.html#palace.decoder_factories">decoder_factories (in module palace)</a>
</li>
<li><a href="reference/context.html#palace.Context.default_resampler_index">default_resampler_index() (palace.Context property)</a>
</li>
<li><a href="reference/effect.html#palace.ChorusEffect.delay">delay (palace.ChorusEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.density">density (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ChorusEffect.depth">depth (palace.ChorusEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.BaseEffect.destroy">destroy() (palace.BaseEffect method)</a>
<ul>
<li><a href="reference/buffer.html#palace.Buffer.destroy">(palace.Buffer method)</a>
</li>
<li><a href="reference/context.html#palace.Context.destroy">(palace.Context method)</a>
</li>
<li><a href="reference/source.html#palace.Source.destroy">(palace.Source method)</a>
</li>
<li><a href="reference/source.html#palace.SourceGroup.destroy">(palace.SourceGroup method)</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/device.html#palace.Device">Device (class in palace)</a>
</li>
<li><a href="reference/context.html#palace.Context.device">device (palace.Context attribute)</a>
</li>
<li><a href="reference/context.html#palace.MessageHandler.device_disconnected">device_disconnected() (palace.MessageHandler method)</a>
</li>
<li><a href="reference/device.html#palace.device_names">device_names (in module palace)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.diffusion">diffusion (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/context.html#palace.Context.distance_model">distance_model() (palace.Context property)</a>
</li>
<li><a href="reference/context.html#palace.distance_models">distance_models (in module palace)</a>
</li>
<li><a href="reference/source.html#palace.Source.distance_range">distance_range (palace.Source attribute)</a>
</li>
<li><a href="reference/source.html#palace.Source.doppler_factor">doppler_factor (palace.Source attribute)</a>
</li>
<li><a href="reference/context.html#palace.Context.doppler_factor">doppler_factor() (palace.Context property)</a>
</li>
</ul></td>
</tr></table>
<h2 id="E">E</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/effect.html#palace.ReverbEffect.echo_depth">echo_depth (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.echo_time">echo_time (palace.ReverbEffect attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/device.html#palace.Device.efx_version">efx_version() (palace.Device property)</a>
</li>
<li><a href="reference/context.html#palace.Context.end_batch">end_batch() (palace.Context method)</a>
</li>
</ul></td>
</tr></table>
<h2 id="F">F</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/source.html#palace.Source.fade_out_to_stop">fade_out_to_stop() (palace.Source method)</a>
</li>
<li><a href="reference/effect.html#palace.ChorusEffect.feedback">feedback (palace.ChorusEffect attribute)</a>
</li>
<li><a href="reference/file-io.html#palace.FileIO">FileIO (class in palace)</a>
</li>
<li><a href="reference/source.html#palace.Source.filter">filter() (palace.Source property)</a>
</li>
<li><a href="reference/buffer.html#palace.free">free() (in module palace)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/context.html#palace.FREQUENCY">FREQUENCY (in module palace)</a>
</li>
<li><a href="reference/decoder.html#palace.BaseDecoder.frequency">frequency() (palace.BaseDecoder property)</a>
<ul>
<li><a href="reference/buffer.html#palace.Buffer.frequency">(palace.Buffer property)</a>
</li>
<li><a href="reference/decoder.html#palace.Decoder.frequency">(palace.Decoder property)</a>
</li>
<li><a href="reference/device.html#palace.Device.frequency">(palace.Device property)</a>
</li>
</ul></li>
<li><a href="reference/buffer.html#palace.Buffer.from_decoder">from_decoder() (palace.Buffer static method)</a>
</li>
</ul></td>
</tr></table>
<h2 id="G">G</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/effect.html#palace.ReverbEffect.gain">gain (palace.ReverbEffect attribute)</a>
<ul>
<li><a href="reference/source.html#palace.Source.gain">(palace.Source attribute)</a>
</li>
<li><a href="reference/source.html#palace.SourceGroup.gain">(palace.SourceGroup attribute)</a>
</li>
</ul></li>
<li><a href="reference/context.html#palace.Listener.gain">gain() (palace.Listener property)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/source.html#palace.Source.gain_auto">gain_auto (palace.Source attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.gain_hf">gain_hf (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.gain_lf">gain_lf (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/source.html#palace.Source.gain_range">gain_range (palace.Source attribute)</a>
</li>
<li><a href="reference/source.html#palace.Source.group">group (palace.Source attribute)</a>
</li>
</ul></td>
</tr></table>
<h2 id="H">H</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/effect.html#palace.ReverbEffect.hf_reference">hf_reference (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/context.html#palace.HRTF">HRTF (in module palace)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/device.html#palace.Device.hrtf_enabled">hrtf_enabled() (palace.Device property)</a>
</li>
<li><a href="reference/context.html#palace.HRTF_ID">HRTF_ID (in module palace)</a>
</li>
<li><a href="reference/device.html#palace.Device.hrtf_names">hrtf_names() (palace.Device property)</a>
</li>
</ul></td>
</tr></table>
<h2 id="I">I</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/context.html#palace.Context.is_supported">is_supported() (palace.Context method)</a>
</li>
</ul></td>
</tr></table>
<h2 id="L">L</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/effect.html#palace.ReverbEffect.late_reverb_delay">late_reverb_delay (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.late_reverb_gain">late_reverb_gain (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.late_reverb_pan">late_reverb_pan (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/source.html#palace.Source.latency">latency() (palace.Source property)</a>
</li>
<li><a href="reference/source.html#palace.Source.latency_seconds">latency_seconds() (palace.Source property)</a>
</li>
<li><a href="reference/decoder.html#palace.BaseDecoder.length">length() (palace.BaseDecoder property)</a>
<ul>
<li><a href="reference/buffer.html#palace.Buffer.length">(palace.Buffer property)</a>
</li>
<li><a href="reference/decoder.html#palace.Decoder.length">(palace.Decoder property)</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/buffer.html#palace.Buffer.length_seconds">length_seconds() (palace.Buffer property)</a>
<ul>
<li><a href="reference/decoder.html#palace.Decoder.length_seconds">(palace.Decoder property)</a>
</li>
</ul></li>
<li><a href="reference/effect.html#palace.ReverbEffect.lf_reference">lf_reference (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/context.html#palace.Listener">Listener (class in palace)</a>
</li>
<li><a href="reference/context.html#palace.Context.listener">listener (palace.Context attribute)</a>
</li>
<li><a href="reference/buffer.html#palace.Buffer.loop_points">loop_points (palace.Buffer attribute)</a>
</li>
<li><a href="reference/decoder.html#palace.BaseDecoder.loop_points">loop_points() (palace.BaseDecoder property)</a>
<ul>
<li><a href="reference/decoder.html#palace.Decoder.loop_points">(palace.Decoder property)</a>
</li>
</ul></li>
<li><a href="reference/source.html#palace.Source.looping">looping (palace.Source attribute)</a>
</li>
</ul></td>
</tr></table>
<h2 id="M">M</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/context.html#palace.MAX_AUXILIARY_SENDS">MAX_AUXILIARY_SENDS (in module palace)</a>
</li>
<li><a href="reference/device.html#palace.Device.max_auxiliary_sends">max_auxiliary_sends() (palace.Device property)</a>
</li>
<li><a href="reference/context.html#palace.Context.message_handler">message_handler (palace.Context attribute)</a>
</li>
<li><a href="reference/context.html#palace.MessageHandler">MessageHandler (class in palace)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/context.html#palace.Listener.meters_per_unit">meters_per_unit() (palace.Listener property)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.modulation_depth">modulation_depth (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.modulation_time">modulation_time (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/context.html#palace.MONO_SOURCES">MONO_SOURCES (in module palace)</a>
</li>
</ul></td>
</tr></table>
<h2 id="N">N</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/buffer.html#palace.Buffer.name">name (palace.Buffer attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/device.html#palace.Device.name">name() (palace.Device property)</a>
</li>
</ul></td>
</tr></table>
<h2 id="O">O</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/source.html#palace.Source.offset">offset (palace.Source attribute)</a>
</li>
<li><a href="reference/source.html#palace.Source.offset_seconds">offset_seconds() (palace.Source property)</a>
</li>
<li><a href="reference/source.html#palace.Source.orientation">orientation (palace.Source attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/context.html#palace.Listener.orientation">orientation() (palace.Listener property)</a>
</li>
<li><a href="reference/source.html#palace.Source.outer_cone_gains">outer_cone_gains (palace.Source attribute)</a>
</li>
<li><a href="reference/context.html#palace.OUTPUT_LIMITER">OUTPUT_LIMITER (in module palace)</a>
</li>
</ul></td>
</tr></table>
<h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/source.html#palace.SourceGroup.parent_group">parent_group (palace.SourceGroup attribute)</a>
</li>
<li><a href="reference/source.html#palace.Source.pause">pause() (palace.Source method)</a>
</li>
<li><a href="reference/source.html#palace.SourceGroup.pause_all">pause_all() (palace.SourceGroup method)</a>
</li>
<li><a href="reference/device.html#palace.Device.pause_dsp">pause_dsp() (palace.Device method)</a>
</li>
<li><a href="reference/source.html#palace.Source.paused">paused() (palace.Source property)</a>
</li>
<li><a href="reference/effect.html#palace.ChorusEffect.phase">phase (palace.ChorusEffect attribute)</a>
</li>
<li><a href="reference/source.html#palace.Source.pitch">pitch (palace.Source attribute)</a>
<ul>
<li><a href="reference/source.html#palace.SourceGroup.pitch">(palace.SourceGroup attribute)</a>
</li>
</ul></li>
<li><a href="reference/buffer.html#palace.Buffer.play">play() (palace.Buffer method)</a>
<ul>
<li><a href="reference/decoder.html#palace.Decoder.play">(palace.Decoder method)</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/source.html#palace.Source.playing">playing() (palace.Source property)</a>
</li>
<li><a href="reference/source.html#palace.Source.position">position (palace.Source attribute)</a>
</li>
<li><a href="reference/context.html#palace.Listener.position">position() (palace.Listener property)</a>
</li>
<li><a href="reference/source.html#palace.Source.priority">priority (palace.Source attribute)</a>
</li>
<li>
Python Enhancement Proposals
<ul>
<li><a href="contributing.html#index-1">PEP 257</a>
</li>
<li><a href="contributing.html#index-0">PEP 8</a>
</li>
<li><a href="index.html#index-0">PEP 8#naming-conventions</a>
</li>
</ul></li>
</ul></td>
</tr></table>
<h2 id="Q">Q</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/device.html#palace.query_extension">query_extension() (in module palace)</a>
<ul>
<li><a href="reference/device.html#palace.Device.query_extension">(palace.Device method)</a>
</li>
</ul></li>
</ul></td>
</tr></table>
<h2 id="R">R</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/source.html#palace.Source.radius">radius (palace.Source attribute)</a>
</li>
<li><a href="reference/decoder.html#palace.BaseDecoder.read">read() (palace.BaseDecoder method)</a>
<ul>
<li><a href="reference/decoder.html#palace.Decoder.read">(palace.Decoder method)</a>
</li>
<li><a href="reference/file-io.html#palace.FileIO.read">(palace.FileIO method)</a>
</li>
</ul></li>
<li><a href="reference/effect.html#palace.ReverbEffect.reflections_delay">reflections_delay (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.reflections_gain">reflections_gain (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.reflections_pan">reflections_pan (palace.ReverbEffect attribute)</a>
</li>
<li><a href="reference/source.html#palace.Source.relative">relative (palace.Source attribute)</a>
</li>
<li><a href="reference/source.html#palace.Source.resampler_index">resampler_index (palace.Source attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/device.html#palace.Device.reset">reset() (palace.Device method)</a>
</li>
<li><a href="reference/context.html#palace.MessageHandler.resource_not_found">resource_not_found() (palace.MessageHandler method)</a>
</li>
<li><a href="reference/source.html#palace.Source.resume">resume() (palace.Source method)</a>
</li>
<li><a href="reference/source.html#palace.SourceGroup.resume_all">resume_all() (palace.SourceGroup method)</a>
</li>
<li><a href="reference/device.html#palace.Device.resume_dsp">resume_dsp() (palace.Device method)</a>
</li>
<li><a href="reference/effect.html#palace.reverb_preset_names">reverb_preset_names (in module palace)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect">ReverbEffect (class in palace)</a>
</li>
<li><a href="reference/source.html#palace.Source.rolloff_factors">rolloff_factors (palace.Source attribute)</a>
</li>
<li><a href="reference/effect.html#palace.ReverbEffect.room_rolloff_factor">room_rolloff_factor (palace.ReverbEffect attribute)</a>
</li>
</ul></td>
</tr></table>
<h2 id="S">S</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/decoder.html#palace.sample_length">sample_length() (in module palace)</a>
</li>
<li><a href="reference/decoder.html#palace.sample_size">sample_size() (in module palace)</a>
</li>
<li><a href="reference/context.html#palace.SAMPLE_TYPE">SAMPLE_TYPE (in module palace)</a>
</li>
<li><a href="reference/decoder.html#palace.BaseDecoder.sample_type">sample_type() (palace.BaseDecoder property)</a>
<ul>
<li><a href="reference/buffer.html#palace.Buffer.sample_type">(palace.Buffer property)</a>
</li>
<li><a href="reference/decoder.html#palace.Decoder.sample_type">(palace.Decoder property)</a>
</li>
</ul></li>
<li><a href="reference/decoder.html#palace.sample_types">sample_types (in module palace)</a>
</li>
<li><a href="reference/decoder.html#palace.BaseDecoder.seek">seek() (palace.BaseDecoder method)</a>
<ul>
<li><a href="reference/decoder.html#palace.Decoder.seek">(palace.Decoder method)</a>
</li>
<li><a href="reference/file-io.html#palace.FileIO.seek">(palace.FileIO method)</a>
</li>
</ul></li>
<li><a href="reference/effect.html#palace.ReverbEffect.send_auto">send_auto() (palace.ReverbEffect property)</a>
</li>
<li><a href="reference/source.html#palace.Source.sends">sends() (palace.Source property)</a>
</li>
<li><a href="reference/buffer.html#palace.Buffer.size">size() (palace.Buffer property)</a>
</li>
<li><a href="reference/effect.html#palace.BaseEffect.slot_gain">slot_gain() (palace.BaseEffect property)</a>
</li>
<li><a href="reference/source.html#palace.Source">Source (class in palace)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/buffer.html#palace.Buffer.source_count">source_count() (palace.Buffer property)</a>
</li>
<li><a href="reference/context.html#palace.MessageHandler.source_force_stopped">source_force_stopped() (palace.MessageHandler method)</a>
</li>
<li><a href="reference/effect.html#palace.BaseEffect.source_sends">source_sends() (palace.BaseEffect property)</a>
</li>
<li><a href="reference/context.html#palace.MessageHandler.source_stopped">source_stopped() (palace.MessageHandler method)</a>
</li>
<li><a href="reference/source.html#palace.SourceGroup">SourceGroup (class in palace)</a>
</li>
<li><a href="reference/buffer.html#palace.Buffer.sources">sources() (palace.Buffer property)</a>
<ul>
<li><a href="reference/source.html#palace.SourceGroup.sources">(palace.SourceGroup property)</a>
</li>
</ul></li>
<li><a href="reference/source.html#palace.Source.spatialize">spatialize (palace.Source attribute)</a>
</li>
<li><a href="reference/context.html#palace.Context.speed_of_sound">speed_of_sound() (palace.Context property)</a>
</li>
<li><a href="reference/context.html#palace.Context.start_batch">start_batch() (palace.Context method)</a>
</li>
<li><a href="reference/source.html#palace.Source.stereo_angles">stereo_angles (palace.Source attribute)</a>
</li>
<li><a href="reference/context.html#palace.STEREO_SOURCES">STEREO_SOURCES (in module palace)</a>
</li>
<li><a href="reference/source.html#palace.Source.stop">stop() (palace.Source method)</a>
</li>
<li><a href="reference/source.html#palace.SourceGroup.stop_all">stop_all() (palace.SourceGroup method)</a>
</li>
<li><a href="reference/source.html#palace.SourceGroup.sub_groups">sub_groups() (palace.SourceGroup property)</a>
</li>
</ul></td>
</tr></table>
<h2 id="T">T</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/context.html#palace.thread_local">thread_local() (in module palace)</a>
</li>
</ul></td>
</tr></table>
<h2 id="U">U</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/context.html#palace.Context.update">update() (palace.Context method)</a>
</li>
<li><a href="reference/context.html#palace.use_context">use_context() (in module palace)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/effect.html#palace.BaseEffect.use_count">use_count() (palace.BaseEffect property)</a>
</li>
<li><a href="reference/file-io.html#palace.use_fileio">use_fileio() (in module palace)</a>
</li>
</ul></td>
</tr></table>
<h2 id="V">V</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/source.html#palace.Source.velocity">velocity (palace.Source attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/context.html#palace.Listener.velocity">velocity() (palace.Listener property)</a>
</li>
</ul></td>
</tr></table>
<h2 id="W">W</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/effect.html#palace.ChorusEffect.waveform">waveform (palace.ChorusEffect attribute)</a>
</li>
</ul></td>
</tr></table>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
</div>
</body>
</html>

View File

@ -1,204 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Installation" href="installation.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="#">Table of Contents</a></h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
<a href="installation.html" title="Next document">Installation</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="overview">
<h1>Overview<a class="headerlink" href="#overview" title="Permalink to this headline"></a></h1>
<p>Pythonic Audio Library and Codecs Environment provides common higher-level API
for audio rendering using OpenAL:</p>
<ul class="simple">
<li><p>3D positional rendering, with <a class="reference external" href="https://en.wikipedia.org/wiki/Head-related_transfer_function">HRTF</a> support for stereo systems</p></li>
<li><p>Environmental effects: reverb, atmospheric air absorption,
sound occlusion and obstruction</p></li>
<li><p>Out-of-the-box codec support: FLAC, MP3, Ogg Vorbis, Opus, WAV, AIFF, etc.</p></li>
</ul>
<p>Palace wraps around the C++ interface <a class="reference external" href="https://github.com/kcat/alure">alure</a> using <a class="reference external" href="https://cython.org">Cython</a> for a safe and
convenient interface with type hinting, data descriptors and context managers,
following <span class="target" id="index-0"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0008#naming-conventions"><strong>PEP 8#naming-conventions</strong></a> (<code class="docutils literal notranslate"><span class="pre">PascalCase.snake_case</span></code>).</p>
<div class="section" id="table-of-contents">
<h2>Table of Contents<a class="headerlink" href="#table-of-contents" title="Permalink to this headline"></a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="installation.html#prerequisites">Prerequisites</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#via-pypi">Via PyPI</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#from-source">From source</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="tutorial/index.html">Tutorial</a><ul>
<li class="toctree-l2"><a class="reference internal" href="tutorial/context.html">Context Creation</a></li>
<li class="toctree-l2"><a class="reference internal" href="tutorial/play-audio.html">Play an Audio</a></li>
<li class="toctree-l2"><a class="reference internal" href="tutorial/source.html">Source Manipulation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a><ul>
<li class="toctree-l2"><a class="reference internal" href="reference/device.html">Audio Devices</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference/context.html">Audio Library Contexts</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference/buffer.html">Resource Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference/source.html">Sources &amp; Source Groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference/effect.html">Environmental Effects</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference/decoder.html">Audio Streams</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference/file-io.html">File I/O Interface</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="design.html">Design Principles</a><ul>
<li class="toctree-l2"><a class="reference internal" href="design.html#the-impl-idiom">The Impl Idiom</a></li>
<li class="toctree-l2"><a class="reference internal" href="design.html#the-modern-python">The Modern Python</a></li>
<li class="toctree-l2"><a class="reference internal" href="design.html#the-double-reference">The Double Reference</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Getting Involved</a><ul>
<li class="toctree-l2"><a class="reference internal" href="contributing.html#reporting-a-bug">Reporting a Bug</a></li>
<li class="toctree-l2"><a class="reference internal" href="contributing.html#requesting-a-feature">Requesting a Feature</a></li>
<li class="toctree-l2"><a class="reference internal" href="contributing.html#submitting-a-patch">Submitting a Patch</a></li>
<li class="toctree-l2"><a class="reference internal" href="contributing.html#making-a-release">Making a Release</a></li>
<li class="toctree-l2"><a class="reference internal" href="contributing.html#style-guidelines">Style Guidelines</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="copying.html">Copying</a><ul>
<li class="toctree-l2"><a class="reference internal" href="copying.html#license">License</a></li>
<li class="toctree-l2"><a class="reference internal" href="copying.html#credits">Credits</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="section" id="indices-and-tables">
<h2>Indices and Tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li>
<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li>
<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
</ul>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
<a href="installation.html" title="Next document">Installation</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/index.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,177 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Installation &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Tutorial" href="tutorial/index.html" />
<link rel="prev" title="Overview" href="index.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Installation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#prerequisites">Prerequisites</a></li>
<li class="toctree-l2"><a class="reference internal" href="#via-pypi">Via PyPI</a></li>
<li class="toctree-l2"><a class="reference internal" href="#from-source">From source</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="index.html" title="Previous document">Overview</a>
</li>
<li>
<a href="tutorial/index.html" title="Next document">Tutorial</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h1>
<div class="section" id="prerequisites">
<h2>Prerequisites<a class="headerlink" href="#prerequisites" title="Permalink to this headline"></a></h2>
<p>Palace requires <a class="reference external" href="https://www.python.org/">CPython</a> version 3.6 or above for runtime
and <a class="reference external" href="https://pip.pypa.io/en/latest/">pip</a> for installation.</p>
</div>
<div class="section" id="via-pypi">
<h2>Via PyPI<a class="headerlink" href="#via-pypi" title="Permalink to this headline"></a></h2>
<p>Palace can be installed from PyPI:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">palace</span>
</pre></div>
</div>
<p>Wheel distributions are built exclusively for amd64. Currently, only GNU/Linux
and macOS are properly supported. If you want to help packaging for Windows,
please see <a class="reference external" href="https://github.com/McSinyx/palace/issues/1">GH-1</a> on our issues tracker on GitHub.</p>
</div>
<div class="section" id="from-source">
<h2>From source<a class="headerlink" href="#from-source" title="Permalink to this headline"></a></h2>
<p>Aside from the build dependencies listed in <code class="docutils literal notranslate"><span class="pre">pyproject.toml</span></code>,
one will additionally need compatible Python headers, <a class="reference external" href="https://github.com/kcat/alure">alure</a>,
a C++14 compiler, <a class="reference external" href="https://cmake.org/">CMake</a> 2.6+ (and probably <a class="reference external" href="https://git-scm.com/">git</a> for fetching the source).
Palace can then be compiled and installed by running:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">McSinyx</span><span class="o">/</span><span class="n">palace</span><span class="o">.</span><span class="n">git</span>
<span class="n">pip</span> <span class="n">install</span> <span class="n">palace</span><span class="o">/</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="index.html" title="Previous document">Overview</a>
</li>
<li>
<a href="tutorial/index.html" title="Next document">Tutorial</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/installation.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

Binary file not shown.

View File

@ -1,351 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Resource Caching &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Sources &amp; Source Groups" href="source.html" />
<link rel="prev" title="Audio Library Contexts" href="context.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="device.html">Audio Devices</a></li>
<li class="toctree-l2"><a class="reference internal" href="context.html">Audio Library Contexts</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Resource Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html">Sources &amp; Source Groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="effect.html">Environmental Effects</a></li>
<li class="toctree-l2"><a class="reference internal" href="decoder.html">Audio Streams</a></li>
<li class="toctree-l2"><a class="reference internal" href="file-io.html">File I/O Interface</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="context.html" title="Previous document">Audio Library Contexts</a>
</li>
<li>
<a href="source.html" title="Next document">Sources &amp; Source Groups</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="resource-caching">
<h1>Resource Caching<a class="headerlink" href="#resource-caching" title="Permalink to this headline"></a></h1>
<div class="section" id="audio-buffers">
<h2>Audio Buffers<a class="headerlink" href="#audio-buffers" title="Permalink to this headline"></a></h2>
<dl class="py class">
<dt id="palace.Buffer">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">Buffer</code><a class="headerlink" href="#palace.Buffer" title="Permalink to this definition"></a></dt>
<dd><p>Buffer of preloaded PCM samples coming from a <cite>Decoder</cite>.</p>
<p>Cached buffers must be freed using <cite>destroy</cite> before destroying
<cite>context</cite>. Alternatively, this can be used as a context manager
that calls <cite>destroy</cite> upon completion of the block,
even if an error occurs.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<em>str</em>) Audio file or resource name. Multiple calls with the same name
will return the same buffer.</p></li>
<li><p><strong>context</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="context.html#palace.Context" title="palace.Context"><em>Context</em></a><em>]</em><em>, </em><em>optional</em>) The context from which the buffer is to be created and cached.
By default <cite>current_context()</cite> is used.</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt id="palace.Buffer.name">
<code class="sig-name descname">name</code><a class="headerlink" href="#palace.Buffer.name" title="Permalink to this definition"></a></dt>
<dd><p>Audio file or resource name.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p>str</p>
</dd>
</dl>
</dd></dl>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>RuntimeError</strong> If there is neither any context specified nor current.</p>
</dd>
</dl>
<dl class="py method">
<dt id="palace.Buffer.channel_config">
<em class="property">property </em><code class="sig-name descname">channel_config</code><a class="headerlink" href="#palace.Buffer.channel_config" title="Permalink to this definition"></a></dt>
<dd><p>Buffers sample configuration.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Buffer.destroy">
<code class="sig-name descname">destroy</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Buffer.destroy" title="Permalink to this definition"></a></dt>
<dd><p>Free the buffers cache.</p>
<p>This invalidates all other <cite>Buffer</cite> objects with the same name.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Buffer.frequency">
<em class="property">property </em><code class="sig-name descname">frequency</code><a class="headerlink" href="#palace.Buffer.frequency" title="Permalink to this definition"></a></dt>
<dd><p>Buffers frequency in hertz.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Buffer.from_decoder">
<em class="property">static </em><code class="sig-name descname">from_decoder</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">decoder</span><span class="p">:</span> <span class="n"><a class="reference internal" href="decoder.html#palace.Decoder" title="palace.Decoder">palace.Decoder</a></span></em>, <em class="sig-param"><span class="n">name</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">context</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span><a class="reference internal" href="context.html#palace.Context" title="palace.Context">palace.Context</a><span class="p">]</span></span></em><span class="sig-paren">)</span> &#x2192; <a class="reference internal" href="#palace.Buffer" title="palace.Buffer">palace.Buffer</a><a class="headerlink" href="#palace.Buffer.from_decoder" title="Permalink to this definition"></a></dt>
<dd><p>Return a buffer created by reading the given decoder.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>decoder</strong> (<a class="reference internal" href="decoder.html#palace.Decoder" title="palace.Decoder"><em>Decoder</em></a>) The decoder from which the buffer is to be cached.</p></li>
<li><p><strong>name</strong> (<em>str</em>) The name to give to the buffer. It may alias an audio file,
but it must not currently exist in the buffer cache.</p></li>
<li><p><strong>context</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="context.html#palace.Context" title="palace.Context"><em>Context</em></a><em>]</em><em>, </em><em>optional</em>) The context from which the buffer is to be created.
By default <cite>current_context()</cite> is used.</p></li>
</ul>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>RuntimeError</strong> If there is neither any context specified nor current;
or if <cite>name</cite> is already used for another buffer.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="palace.Buffer.length">
<em class="property">property </em><code class="sig-name descname">length</code><a class="headerlink" href="#palace.Buffer.length" title="Permalink to this definition"></a></dt>
<dd><p>Length of the buffer in sample frames.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Buffer.length_seconds">
<em class="property">property </em><code class="sig-name descname">length_seconds</code><a class="headerlink" href="#palace.Buffer.length_seconds" title="Permalink to this definition"></a></dt>
<dd><p>Length of the buffer in seconds.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Buffer.loop_points">
<code class="sig-name descname">loop_points</code><a class="headerlink" href="#palace.Buffer.loop_points" title="Permalink to this definition"></a></dt>
<dd><p>Loop points for looping sources.</p>
<p>If <cite>AL_SOFT_loop_points</cite> extension is not supported by the
current context, <cite>start = 0</cite> and <cite>end = length</cite> respectively.
Otherwise, <cite>start &lt; end &lt;= length</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><ul class="simple">
<li><p><strong>start</strong> (<em>int</em>) Starting point, in sample frames (inclusive).</p></li>
<li><p><strong>end</strong> (<em>int</em>) Ending point, in sample frames (exclusive).</p></li>
</ul>
</p>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>The buffer must not be in use when this property is set.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Buffer.play">
<code class="sig-name descname">play</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">source</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span><a class="reference internal" href="source.html#palace.Source" title="palace.Source">palace.Source</a><span class="p">]</span></span></em><span class="sig-paren">)</span> &#x2192; <a class="reference internal" href="source.html#palace.Source" title="palace.Source">palace.Source</a><a class="headerlink" href="#palace.Buffer.play" title="Permalink to this definition"></a></dt>
<dd><p>Play <cite>source</cite> using the buffer.</p>
<p>Return the source used for playing. If <cite>None</cite> is given,
create a new one.</p>
<p>One buffer may be played from multiple sources simultaneously.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Buffer.sample_type">
<em class="property">property </em><code class="sig-name descname">sample_type</code><a class="headerlink" href="#palace.Buffer.sample_type" title="Permalink to this definition"></a></dt>
<dd><p>Buffers sample type.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Buffer.size">
<em class="property">property </em><code class="sig-name descname">size</code><a class="headerlink" href="#palace.Buffer.size" title="Permalink to this definition"></a></dt>
<dd><p>Storage size used by the buffer, in bytes.</p>
<p class="rubric">Notes</p>
<p>The size in bytes may not be what you expect from the length,
as it may take more space internally than the <cite>channel_config</cite>
and <cite>sample_type</cite> suggest.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Buffer.source_count">
<em class="property">property </em><code class="sig-name descname">source_count</code><a class="headerlink" href="#palace.Buffer.source_count" title="Permalink to this definition"></a></dt>
<dd><p>Number of sources currently using the buffer.</p>
<p class="rubric">Notes</p>
<p><cite>Context.update</cite> needs to be called to reliably ensure the count
is kept updated for when sources reach their end. This is
equivalent to calling <cite>len(self.sources)</cite>.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Buffer.sources">
<em class="property">property </em><code class="sig-name descname">sources</code><a class="headerlink" href="#palace.Buffer.sources" title="Permalink to this definition"></a></dt>
<dd><p><cite>Source</cite> objects currently playing the buffer.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="loading-freeing-in-batch">
<h2>Loading &amp; Freeing in Batch<a class="headerlink" href="#loading-freeing-in-batch" title="Permalink to this headline"></a></h2>
<dl class="py function">
<dt id="palace.cache">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">cache</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">names</span><span class="p">:</span> <span class="n">Iterable<span class="p">[</span>str<span class="p">]</span></span></em>, <em class="sig-param"><span class="n">context</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span><a class="reference internal" href="context.html#palace.Context" title="palace.Context">palace.Context</a><span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.cache" title="Permalink to this definition"></a></dt>
<dd><p>Cache given audio resources asynchronously.</p>
<p>Duplicate names and buffers already cached are ignored.
Cached buffers must be freed before destroying the context.</p>
<p>The resources will be scheduled for caching asynchronously,
and should be retrieved later when needed by initializing
<cite>Buffer</cite> corresponding objects. Resources that cannot be
loaded, for example due to an unsupported format, will be
ignored and a later <cite>Buffer</cite> initialization will raise
an exception.</p>
<p>If <cite>context</cite> is not given, <cite>current_context()</cite> will be used.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>RuntimeError</strong> If there is neither any context specified nor current.</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#palace.free" title="palace.free"><code class="xref py py-func docutils literal notranslate"><span class="pre">free()</span></code></a></dt><dd><p>Free cached audio resources given their names</p>
</dd>
<dt><a class="reference internal" href="#palace.Buffer.destroy" title="palace.Buffer.destroy"><code class="xref py py-func docutils literal notranslate"><span class="pre">Buffer.destroy()</span></code></a></dt><dd><p>Free the buffers cache</p>
</dd>
</dl>
</div>
</dd></dl>
<dl class="py function">
<dt id="palace.free">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">free</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">names</span><span class="p">:</span> <span class="n">Iterable<span class="p">[</span>str<span class="p">]</span></span></em>, <em class="sig-param"><span class="n">context</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span><a class="reference internal" href="context.html#palace.Context" title="palace.Context">palace.Context</a><span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.free" title="Permalink to this definition"></a></dt>
<dd><p>Free cached audio resources given their names.</p>
<p>If <cite>context</cite> is not given, <cite>current_context()</cite> will be used.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>RuntimeError</strong> If there is neither any context specified nor current.</p>
</dd>
</dl>
</dd></dl>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="context.html" title="Previous document">Audio Library Contexts</a>
</li>
<li>
<a href="source.html" title="Next document">Sources &amp; Source Groups</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/reference/buffer.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,581 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Audio Library Contexts &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Resource Caching" href="buffer.html" />
<link rel="prev" title="Audio Devices" href="device.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="device.html">Audio Devices</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Audio Library Contexts</a></li>
<li class="toctree-l2"><a class="reference internal" href="buffer.html">Resource Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html">Sources &amp; Source Groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="effect.html">Environmental Effects</a></li>
<li class="toctree-l2"><a class="reference internal" href="decoder.html">Audio Streams</a></li>
<li class="toctree-l2"><a class="reference internal" href="file-io.html">File I/O Interface</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="device.html" title="Previous document">Audio Devices</a>
</li>
<li>
<a href="buffer.html" title="Next document">Resource Caching</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="audio-library-contexts">
<h1>Audio Library Contexts<a class="headerlink" href="#audio-library-contexts" title="Permalink to this headline"></a></h1>
<div class="section" id="context-and-auxiliary-classes">
<h2>Context and Auxiliary Classes<a class="headerlink" href="#context-and-auxiliary-classes" title="Permalink to this headline"></a></h2>
<dl class="py class">
<dt id="palace.Context">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">Context</code><a class="headerlink" href="#palace.Context" title="Permalink to this definition"></a></dt>
<dd><p>Container maintaining the audio environment.</p>
<p>Context contains the environments settings and components
such as sources, buffers and effects.</p>
<p>This can be used as a context manager, e.g.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="n">context</span><span class="p">:</span>
<span class="o">...</span>
</pre></div>
</div>
<p>is equivalent to</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">previous</span> <span class="o">=</span> <span class="n">current_context</span><span class="p">()</span>
<span class="n">use_context</span><span class="p">(</span><span class="n">context</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="o">...</span>
<span class="k">finally</span><span class="p">:</span>
<span class="n">use_context</span><span class="p">(</span><span class="n">previous</span><span class="p">)</span>
<span class="n">context</span><span class="o">.</span><span class="n">destroy</span><span class="p">()</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>device</strong> (<a class="reference internal" href="device.html#palace.Device" title="palace.Device"><em>Device</em></a>) The <cite>device</cite> on which the context is to be created.</p></li>
<li><p><strong>attrs</strong> (<em>Dict</em><em>[</em><em>int</em><em>, </em><em>int</em><em>]</em>) Attributes specified for the context to be created.</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt id="palace.Context.device">
<code class="sig-name descname">device</code><a class="headerlink" href="#palace.Context.device" title="Permalink to this definition"></a></dt>
<dd><p>The device this context was created from.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><a class="reference internal" href="device.html#palace.Device" title="palace.Device">Device</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Context.listener">
<code class="sig-name descname">listener</code><a class="headerlink" href="#palace.Context.listener" title="Permalink to this definition"></a></dt>
<dd><p>The listener instance of this context.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#palace.Listener" title="palace.Listener">Listener</a></p>
</dd>
</dl>
</dd></dl>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>RuntimeError</strong> If context creation fails.</p>
</dd>
</dl>
<dl class="py attribute">
<dt id="palace.Context.async_wake_interval">
<code class="sig-name descname">async_wake_interval</code><a class="headerlink" href="#palace.Context.async_wake_interval" title="Permalink to this definition"></a></dt>
<dd><p>Current interval used for waking up the background thread.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Context.available_resamplers">
<em class="property">property </em><code class="sig-name descname">available_resamplers</code><a class="headerlink" href="#palace.Context.available_resamplers" title="Permalink to this definition"></a></dt>
<dd><p>The list of resamplers supported by the context.</p>
<p>If <cite>AL_SOFT_source_resampler</cite> extension is unsupported,
this will be an empty list. Otherwise there would be
at least one entry.</p>
<p>This method require the context to be current.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Context.default_resampler_index">
<em class="property">property </em><code class="sig-name descname">default_resampler_index</code><a class="headerlink" href="#palace.Context.default_resampler_index" title="Permalink to this definition"></a></dt>
<dd><p>The contexts default resampler index.</p>
<p>If <cite>AL_SOFT_source_resampler</cite> extension is unsupported,
this will return 0.</p>
<p>If you try to access the resampler list with this index
without extension, undefined behavior will occur
(accessing an out of bounds array index).</p>
<p>This method require the context to be current.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Context.destroy">
<code class="sig-name descname">destroy</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Context.destroy" title="Permalink to this definition"></a></dt>
<dd><p>Destroy the context.</p>
<p>The context must not be current when this is called.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Context.distance_model">
<em class="property">property </em><code class="sig-name descname">distance_model</code><a class="headerlink" href="#palace.Context.distance_model" title="Permalink to this definition"></a></dt>
<dd><p>The model for source attenuation based on distance.</p>
<p>The default, inverse clamped, provides a realistic l/r
reduction in volume (that is, every doubling of distance
cause the gain to reduce by half).</p>
<p>The clamped distance models restrict the source distance for
the purpose of distance attenuation, so a source wont sound
closer than its reference distance or farther than its max
distance.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>ValueError</strong> If set to a preset cannot be found in <cite>distance_models</cite>.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="palace.Context.doppler_factor">
<em class="property">property </em><code class="sig-name descname">doppler_factor</code><a class="headerlink" href="#palace.Context.doppler_factor" title="Permalink to this definition"></a></dt>
<dd><p>Factor to apply to all sources doppler calculations.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Context.end_batch">
<code class="sig-name descname">end_batch</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Context.end_batch" title="Permalink to this definition"></a></dt>
<dd><p>Continue processing the context and end batching.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Context.is_supported">
<code class="sig-name descname">is_supported</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">channel_config</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">sample_type</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span> &#x2192; bool<a class="headerlink" href="#palace.Context.is_supported" title="Permalink to this definition"></a></dt>
<dd><p>Return if the channel config and sample type is supported.</p>
<p>This method require the context to be current.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="decoder.html#palace.sample_types" title="palace.sample_types"><code class="xref py py-meth docutils literal notranslate"><span class="pre">sample_types()</span></code></a></dt><dd><p>Set of sample types</p>
</dd>
<dt><a class="reference internal" href="decoder.html#palace.channel_configs" title="palace.channel_configs"><code class="xref py py-meth docutils literal notranslate"><span class="pre">channel_configs()</span></code></a></dt><dd><p>Set of channel configurations</p>
</dd>
</dl>
</div>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Context.message_handler">
<code class="sig-name descname">message_handler</code><a class="headerlink" href="#palace.Context.message_handler" title="Permalink to this definition"></a></dt>
<dd><p>Handler of some certain events.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Context.speed_of_sound">
<em class="property">property </em><code class="sig-name descname">speed_of_sound</code><a class="headerlink" href="#palace.Context.speed_of_sound" title="Permalink to this definition"></a></dt>
<dd><p>The speed of sound propagation in units per second.</p>
<p>It is used to calculate the doppler effect along with other
distance-related time effects.</p>
<p>The default is 343.3 units per second (a realistic speed
assuming 1 meter per unit). If this is adjusted for a
different unit scale, <cite>Listener.meters_per_unit</cite> should
also be adjusted.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Context.start_batch">
<code class="sig-name descname">start_batch</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Context.start_batch" title="Permalink to this definition"></a></dt>
<dd><p>Suspend the context to start batching.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Context.update">
<code class="sig-name descname">update</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Context.update" title="Permalink to this definition"></a></dt>
<dd><p>Update the context and all sources belonging to this context.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="palace.Listener">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">Listener</code><a class="headerlink" href="#palace.Listener" title="Permalink to this definition"></a></dt>
<dd><p>Listener instance of the given context.</p>
<p>It is recommended that applications access the listener via
<cite>Context.listener</cite>, which avoid the overhead caused by the
creation of the wrapper object.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>context</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="#palace.Context" title="palace.Context"><em>Context</em></a><em>]</em><em>, </em><em>optional</em>) The context on which the listener instance is to be created.
By default <cite>current_context()</cite> is used.</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>RuntimeError</strong> If there is neither any context specified nor current.</p>
</dd>
</dl>
<dl class="py method">
<dt id="palace.Listener.gain">
<em class="property">property </em><code class="sig-name descname">gain</code><a class="headerlink" href="#palace.Listener.gain" title="Permalink to this definition"></a></dt>
<dd><p>Master gain for all context output.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Listener.meters_per_unit">
<em class="property">property </em><code class="sig-name descname">meters_per_unit</code><a class="headerlink" href="#palace.Listener.meters_per_unit" title="Permalink to this definition"></a></dt>
<dd><p>Number of meters per unit.</p>
<p>This is used for various effects relying on the distance
in meters including air absorption and initial reverb decay.
If this is changed, so should the speed of sound
(e.g. <cite>context.speed_of_sound = 343.3 / meters_per_unit</cite>
to maintain a realistic 343.3 m/s for sound propagation).</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Listener.orientation">
<em class="property">property </em><code class="sig-name descname">orientation</code><a class="headerlink" href="#palace.Listener.orientation" title="Permalink to this definition"></a></dt>
<dd><p>3D orientation of the listener.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>at</strong> (<em>Tuple</em><em>[</em><em>float</em><em>, </em><em>float</em><em>, </em><em>float</em><em>]</em>) Relative position.</p></li>
<li><p><strong>up</strong> (<em>Tuple</em><em>[</em><em>float</em><em>, </em><em>float</em><em>, </em><em>float</em><em>]</em>) Relative direction.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="palace.Listener.position">
<em class="property">property </em><code class="sig-name descname">position</code><a class="headerlink" href="#palace.Listener.position" title="Permalink to this definition"></a></dt>
<dd><p>3D position of the listener.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Listener.velocity">
<em class="property">property </em><code class="sig-name descname">velocity</code><a class="headerlink" href="#palace.Listener.velocity" title="Permalink to this definition"></a></dt>
<dd><p>3D velocity of the listener, in units per second.</p>
<p>As with OpenAL, this does not actually alter the listeners
position, and instead just alters the pitch as determined by
the doppler effect.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="palace.MessageHandler">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">MessageHandler</code><a class="headerlink" href="#palace.MessageHandler" title="Permalink to this definition"></a></dt>
<dd><p>Message handler interface.</p>
<p>Applications may derive from this and set an instance on a context
to receive messages. The base methods are no-ops, so subclasses
only need to implement methods for relevant messages.</p>
<p>Exceptions raised from <cite>MessageHandler</cite> instances are ignored.</p>
<dl class="py method">
<dt id="palace.MessageHandler.buffer_loading">
<code class="sig-name descname">buffer_loading</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">channel_config</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">sample_type</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">sample_rate</span><span class="p">:</span> <span class="n">int</span></em>, <em class="sig-param"><span class="n">data</span><span class="p">:</span> <span class="n">Sequence<span class="p">[</span>int<span class="p">]</span></span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.MessageHandler.buffer_loading" title="Permalink to this definition"></a></dt>
<dd><p>Handle messages from Buffer initialization.</p>
<p>This is called when a new buffer is about to be created
and loaded. which may be called asynchronously for buffers
being loaded asynchronously.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<em>str</em>) Resource name passed to <cite>Buffer</cite>.</p></li>
<li><p><strong>channel_config</strong> (<em>str</em>) Channel configuration of the given audio data.</p></li>
<li><p><strong>sample_type</strong> (<em>str</em>) Sample type of the given audio data.</p></li>
<li><p><strong>sample_rate</strong> (<em>int</em>) Sample rate of the given audio data.</p></li>
<li><p><strong>data</strong> (<em>MutableSequence</em><em>[</em><em>int</em><em>]</em>) <p>The audio data that is about to be fed to the OpenAL buffer.</p>
<p>It is a mutable memory array of signed 8-bit integers,
following Python buffer protocol.</p>
</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="palace.MessageHandler.device_disconnected">
<code class="sig-name descname">device_disconnected</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">device</span><span class="p">:</span> <span class="n"><a class="reference internal" href="device.html#palace.Device" title="palace.Device">palace.Device</a></span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.MessageHandler.device_disconnected" title="Permalink to this definition"></a></dt>
<dd><p>Handle disconnected device messages.</p>
<p>This is called when the given device has been disconnected and
is no longer usable for output. As per <cite>ALC_EXT_disconnect</cite>
specification, disconnected devices remain valid, however all
playing sources are automatically stopped, any sources that are
attempted to play will immediately stop, and new contexts may
not be created on the device.</p>
<p class="rubric">Notes</p>
<p>Connection status is checked during <cite>Context.update</cite> calls, so
method must be called regularly to be notified when a device is
disconnected. This method may not be called if the device lacks
support for <cite>ALC_EXT_disconnect</cite> extension.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.MessageHandler.resource_not_found">
<code class="sig-name descname">resource_not_found</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span> &#x2192; str<a class="headerlink" href="#palace.MessageHandler.resource_not_found" title="Permalink to this definition"></a></dt>
<dd><p>Return the fallback resource for the one of the given name.</p>
<p>This is called when <cite>name</cite> is not found, allowing substitution
of a different resource until the returned string either points
to a valid resource or is empty (default).</p>
<p>For buffers being cached, the original name will still be used
for the cache entry so one does not have to keep track of
substituted resource names.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.MessageHandler.source_force_stopped">
<code class="sig-name descname">source_force_stopped</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">source</span><span class="p">:</span> <span class="n"><a class="reference internal" href="source.html#palace.Source" title="palace.Source">palace.Source</a></span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.MessageHandler.source_force_stopped" title="Permalink to this definition"></a></dt>
<dd><p>Handle forcefully stopped sources.</p>
<p>This is called when the given source was forced to stop,
because of one of the following reasons:</p>
<ul class="simple">
<li><p>There were no more mixing sources and a higher-priority source
preempted it.</p></li>
<li><p><cite>source</cite> is part of a <cite>SourceGroup</cite> (or sub-group thereof)
that had its <cite>SourceGroup.stop_all</cite> method called.</p></li>
<li><p><cite>source</cite> was playing a buffer thats getting removed.</p></li>
</ul>
</dd></dl>
<dl class="py method">
<dt id="palace.MessageHandler.source_stopped">
<code class="sig-name descname">source_stopped</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">source</span><span class="p">:</span> <span class="n"><a class="reference internal" href="source.html#palace.Source" title="palace.Source">palace.Source</a></span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.MessageHandler.source_stopped" title="Permalink to this definition"></a></dt>
<dd><p>Handle end-of-buffer/stream messages.</p>
<p>This is called when the given source reaches the end of buffer
or stream, which is detected upon a call to <cite>Context.update</cite>.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="using-contexts">
<h2>Using Contexts<a class="headerlink" href="#using-contexts" title="Permalink to this headline"></a></h2>
<dl class="py function">
<dt id="palace.use_context">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">use_context</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">context</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span><a class="reference internal" href="#palace.Context" title="palace.Context">palace.Context</a><span class="p">]</span></span></em>, <em class="sig-param"><span class="n">thread</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span>bool<span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.use_context" title="Permalink to this definition"></a></dt>
<dd><p>Make the specified context current for OpenAL operations.</p>
<p>This fails silently if the given context has been destroyed.
In case <cite>thread</cite> is not specified, fallback to preference made by
<cite>thread_local</cite>.</p>
<p>If <cite>thread</cite> is <cite>True</cite>, make the context current
for OpenAL operations on the calling thread only.
This requires the non-device-specific as well as the contexts
device <cite>ALC_EXT_thread_local_context</cite> extension to be available.</p>
</dd></dl>
<dl class="py function">
<dt id="palace.current_context">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">current_context</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">thread</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span>bool<span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span> &#x2192; Optional<span class="p">[</span><a class="reference internal" href="#palace.Context" title="palace.Context">palace.Context</a><span class="p">]</span><a class="headerlink" href="#palace.current_context" title="Permalink to this definition"></a></dt>
<dd><p>Return the context that is currently used.</p>
<p>If <cite>thread</cite> is set to <cite>True</cite>, return the thread-specific context
used for OpenAL operations. This requires the non-device-specific
as well as the contexts device <cite>ALC_EXT_thread_local_context</cite>
extension to be available.</p>
<p>In case <cite>thread</cite> is not specified, fallback to preference made by
<cite>thread_local</cite>.</p>
</dd></dl>
<dl class="py function">
<dt id="palace.thread_local">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">thread_local</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">state</span><span class="p">:</span> <span class="n">bool</span></em><span class="sig-paren">)</span> &#x2192; Iterator<span class="p">[</span>None<span class="p">]</span><a class="headerlink" href="#palace.thread_local" title="Permalink to this definition"></a></dt>
<dd><p>Return a context manager controlling preference of local thread.</p>
<p>Effectively, it sets fallback value for <cite>thread</cite> argument
for <cite>current_context</cite> and <cite>use_context</cite>.</p>
<p>Initially, globally current <cite>Context</cite> is preferred.</p>
</dd></dl>
</div>
<div class="section" id="context-creation-attributes">
<h2>Context Creation Attributes<a class="headerlink" href="#context-creation-attributes" title="Permalink to this headline"></a></h2>
<dl class="py data">
<dt id="palace.CHANNEL_CONFIG">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">CHANNEL_CONFIG</code><em class="property">: int</em><a class="headerlink" href="#palace.CHANNEL_CONFIG" title="Permalink to this definition"></a></dt>
<dd><p>Context creation key to specify the channel configuration
(either <code class="docutils literal notranslate"><span class="pre">MONO</span></code>, <code class="docutils literal notranslate"><span class="pre">STEREO</span></code>, <code class="docutils literal notranslate"><span class="pre">QUAD</span></code>, <code class="docutils literal notranslate"><span class="pre">X51</span></code>, <code class="docutils literal notranslate"><span class="pre">X61</span></code> or <code class="docutils literal notranslate"><span class="pre">X71</span></code>).</p>
</dd></dl>
<dl class="py data">
<dt id="palace.SAMPLE_TYPE">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">SAMPLE_TYPE</code><em class="property">: int</em><a class="headerlink" href="#palace.SAMPLE_TYPE" title="Permalink to this definition"></a></dt>
<dd><p>Context creation key to specify the sample type
(either <code class="docutils literal notranslate"><span class="pre">[UNSIGNED_]{BYTE,SHORT,INT}</span></code> or <code class="docutils literal notranslate"><span class="pre">FLOAT</span></code>).</p>
</dd></dl>
<dl class="py data">
<dt id="palace.FREQUENCY">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">FREQUENCY</code><em class="property">: int</em><a class="headerlink" href="#palace.FREQUENCY" title="Permalink to this definition"></a></dt>
<dd><p>Context creation key to specify the frequency in hertz.</p>
</dd></dl>
<dl class="py data">
<dt id="palace.MONO_SOURCES">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">MONO_SOURCES</code><em class="property">: int</em><a class="headerlink" href="#palace.MONO_SOURCES" title="Permalink to this definition"></a></dt>
<dd><p>Context creation key to specify the number of mono (3D) sources.</p>
</dd></dl>
<dl class="py data">
<dt id="palace.STEREO_SOURCES">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">STEREO_SOURCES</code><em class="property">: int</em><a class="headerlink" href="#palace.STEREO_SOURCES" title="Permalink to this definition"></a></dt>
<dd><p>Context creation key to specify the number of stereo sources.</p>
</dd></dl>
<dl class="py data">
<dt id="palace.MAX_AUXILIARY_SENDS">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">MAX_AUXILIARY_SENDS</code><em class="property">: int</em><a class="headerlink" href="#palace.MAX_AUXILIARY_SENDS" title="Permalink to this definition"></a></dt>
<dd><p>Context creation key to specify the maximum number of
auxiliary source sends.</p>
</dd></dl>
<dl class="py data">
<dt id="palace.HRTF">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">HRTF</code><em class="property">: int</em><a class="headerlink" href="#palace.HRTF" title="Permalink to this definition"></a></dt>
<dd><p>Context creation key to specify whether to enable HRTF
(either <code class="docutils literal notranslate"><span class="pre">FALSE</span></code>, <code class="docutils literal notranslate"><span class="pre">TRUE</span></code> or <code class="docutils literal notranslate"><span class="pre">DONT_CARE</span></code>).</p>
</dd></dl>
<dl class="py data">
<dt id="palace.HRTF_ID">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">HRTF_ID</code><em class="property">: int</em><a class="headerlink" href="#palace.HRTF_ID" title="Permalink to this definition"></a></dt>
<dd><p>Context creation key to specify the HRTF to be used.</p>
</dd></dl>
<dl class="py data">
<dt id="palace.OUTPUT_LIMITER">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">OUTPUT_LIMITER</code><em class="property">: int</em><a class="headerlink" href="#palace.OUTPUT_LIMITER" title="Permalink to this definition"></a></dt>
<dd><p>Context creation key to specify whether to use a gain limiter
(either <code class="docutils literal notranslate"><span class="pre">FALSE</span></code>, <code class="docutils literal notranslate"><span class="pre">TRUE</span></code> or <code class="docutils literal notranslate"><span class="pre">DONT_CARE</span></code>).</p>
</dd></dl>
<dl class="py data">
<dt id="palace.distance_models">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">distance_models</code><em class="property">: Tuple<span class="p">[</span>str<span class="p">, </span><span class="p"></span><span class="p">]</span></em><a class="headerlink" href="#palace.distance_models" title="Permalink to this definition"></a></dt>
<dd><p>Names of available distance models.</p>
</dd></dl>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="device.html" title="Previous document">Audio Devices</a>
</li>
<li>
<a href="buffer.html" title="Next document">Resource Caching</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/reference/context.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,431 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Audio Streams &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="File I/O Interface" href="file-io.html" />
<link rel="prev" title="Environmental Effects" href="effect.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="device.html">Audio Devices</a></li>
<li class="toctree-l2"><a class="reference internal" href="context.html">Audio Library Contexts</a></li>
<li class="toctree-l2"><a class="reference internal" href="buffer.html">Resource Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html">Sources &amp; Source Groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="effect.html">Environmental Effects</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Audio Streams</a></li>
<li class="toctree-l2"><a class="reference internal" href="file-io.html">File I/O Interface</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="effect.html" title="Previous document">Environmental Effects</a>
</li>
<li>
<a href="file-io.html" title="Next document">File I/O Interface</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="audio-streams">
<h1>Audio Streams<a class="headerlink" href="#audio-streams" title="Permalink to this headline"></a></h1>
<div class="section" id="builtin-decoders">
<h2>Builtin Decoders<a class="headerlink" href="#builtin-decoders" title="Permalink to this headline"></a></h2>
<dl class="py class">
<dt id="palace.Decoder">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">Decoder</code><a class="headerlink" href="#palace.Decoder" title="Permalink to this definition"></a></dt>
<dd><p>Generic audio decoder.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<em>str</em>) Audio file or resource name.</p></li>
<li><p><strong>context</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="context.html#palace.Context" title="palace.Context"><em>Context</em></a><em>]</em><em>, </em><em>optional</em>) The context from which the decoder is to be created.
By default <cite>current_context()</cite> is used.</p></li>
</ul>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>RuntimeError</strong> If there is neither any context specified nor current.</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="buffer.html#palace.Buffer" title="palace.Buffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Buffer</span></code></a></dt><dd><p>Preloaded PCM samples coming from a <cite>Decoder</cite></p>
</dd>
</dl>
</div>
<p class="rubric">Notes</p>
<p>Due to implementation details, while this creates decoder objects
from filenames using contexts, it is the superclass of the ABC
(abstract base class) <cite>BaseDecoder</cite>. Because of this, <cite>Decoder</cite>
may only initialize an internal one. To use registered factories,
please call the module-level <cite>decode</cite> function instead.</p>
<dl class="py method">
<dt id="palace.Decoder.channel_config">
<em class="property">property </em><code class="sig-name descname">channel_config</code><a class="headerlink" href="#palace.Decoder.channel_config" title="Permalink to this definition"></a></dt>
<dd><p>Channel configuration of the audio being decoded.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Decoder.frequency">
<em class="property">property </em><code class="sig-name descname">frequency</code><a class="headerlink" href="#palace.Decoder.frequency" title="Permalink to this definition"></a></dt>
<dd><p>Sample frequency, in hertz, of the audio being decoded.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Decoder.length">
<em class="property">property </em><code class="sig-name descname">length</code><a class="headerlink" href="#palace.Decoder.length" title="Permalink to this definition"></a></dt>
<dd><p>Length of audio in sample frames, falling-back to 0.</p>
<p class="rubric">Notes</p>
<p>Zero-length decoders may not be used to load a <cite>Buffer</cite>.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Decoder.length_seconds">
<em class="property">property </em><code class="sig-name descname">length_seconds</code><a class="headerlink" href="#palace.Decoder.length_seconds" title="Permalink to this definition"></a></dt>
<dd><p>Length of audio in seconds, falling-back to 0.0.</p>
<p class="rubric">Notes</p>
<p>Zero-length decoders may not be used to load a <cite>Buffer</cite>.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Decoder.loop_points">
<em class="property">property </em><code class="sig-name descname">loop_points</code><a class="headerlink" href="#palace.Decoder.loop_points" title="Permalink to this definition"></a></dt>
<dd><p>Loop points in sample frames.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><ul class="simple">
<li><p><strong>start</strong> (<em>int</em>) Inclusive starting loop point.</p></li>
<li><p><strong>end</strong> (<em>int</em>) Exclusive starting loop point.</p></li>
</ul>
</p>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>If <cite>start &gt;= end</cite>, all available samples are included
in the loop.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Decoder.play">
<code class="sig-name descname">play</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">chunk_len</span><span class="p">:</span> <span class="n">int</span></em>, <em class="sig-param"><span class="n">queue_size</span><span class="p">:</span> <span class="n">int</span></em>, <em class="sig-param"><span class="n">source</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span><a class="reference internal" href="source.html#palace.Source" title="palace.Source">palace.Source</a><span class="p">]</span></span></em><span class="sig-paren">)</span> &#x2192; <a class="reference internal" href="source.html#palace.Source" title="palace.Source">palace.Source</a><a class="headerlink" href="#palace.Decoder.play" title="Permalink to this definition"></a></dt>
<dd><p>Stream audio asynchronously from the decoder.</p>
<p>The decoder must NOT have its <cite>read</cite> or <cite>seek</cite> called
from elsewhere while in use.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>chunk_len</strong> (<em>int</em>) The number of sample frames to read for each chunk update.
Smaller values will require more frequent updates and
larger values will handle more data with each chunk.</p></li>
<li><p><strong>queue_size</strong> (<em>int</em>) The number of chunks to keep queued during playback.
Smaller values use less memory while larger values
improve protection against underruns.</p></li>
<li><p><strong>source</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="source.html#palace.Source" title="palace.Source"><em>Source</em></a><em>]</em><em>, </em><em>optional</em>) The source object to play audio. If <cite>None</cite> is given,
a new one will be created from the current context.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>The source used for playing.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="palace.Decoder.read">
<code class="sig-name descname">read</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">count</span><span class="p">:</span> <span class="n">int</span></em><span class="sig-paren">)</span> &#x2192; bytes<a class="headerlink" href="#palace.Decoder.read" title="Permalink to this definition"></a></dt>
<dd><p>Decode and return <cite>count</cite> sample frames.</p>
<p>If less than the requested count samples is returned,
the end of the audio has been reached.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#palace.sample_length" title="palace.sample_length"><code class="xref py py-meth docutils literal notranslate"><span class="pre">sample_length()</span></code></a></dt><dd><p>length of samples of given size</p>
</dd>
</dl>
</div>
</dd></dl>
<dl class="py method">
<dt id="palace.Decoder.sample_type">
<em class="property">property </em><code class="sig-name descname">sample_type</code><a class="headerlink" href="#palace.Decoder.sample_type" title="Permalink to this definition"></a></dt>
<dd><p>Sample type of the audio being decoded.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Decoder.seek">
<code class="sig-name descname">seek</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">pos</span><span class="p">:</span> <span class="n">int</span></em><span class="sig-paren">)</span> &#x2192; bool<a class="headerlink" href="#palace.Decoder.seek" title="Permalink to this definition"></a></dt>
<dd><p>Seek to <cite>pos</cite>, specified in sample frames.</p>
<p>Return if the seek was successful.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="decoder-interface">
<h2>Decoder Interface<a class="headerlink" href="#decoder-interface" title="Permalink to this headline"></a></h2>
<dl class="py data">
<dt id="palace.decoder_factories">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">decoder_factories</code><em class="property">: DecoderNamespace</em><a class="headerlink" href="#palace.decoder_factories" title="Permalink to this definition"></a></dt>
<dd><p>Simple object for storing decoder factories.</p>
<p>User-registered factories are tried one after another
if <code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code> is raised, in lexicographical order.
Internal decoder factories are always used after registered ones.</p>
</dd></dl>
<dl class="py function">
<dt id="palace.decode">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">decode</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">context</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span><a class="reference internal" href="context.html#palace.Context" title="palace.Context">palace.Context</a><span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span> &#x2192; <a class="reference internal" href="#palace.Decoder" title="palace.Decoder">palace.Decoder</a><a class="headerlink" href="#palace.decode" title="Permalink to this definition"></a></dt>
<dd><p>Return the decoder created from the given resource name.</p>
<p>This first tries user-registered decoder factories in
lexicographical order, then fallback to the internal ones.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>RuntimeError</strong> If there is neither any context specified nor current.</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#palace.decoder_factories" title="palace.decoder_factories"><code class="xref py py-func docutils literal notranslate"><span class="pre">decoder_factories()</span></code></a></dt><dd><p>Simple object for storing decoder factories</p>
</dd>
</dl>
</div>
</dd></dl>
<dl class="py class">
<dt id="palace.BaseDecoder">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">BaseDecoder</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="headerlink" href="#palace.BaseDecoder" title="Permalink to this definition"></a></dt>
<dd><p>Audio decoder interface.</p>
<p>Applications may derive from this, implement necessary methods,
and use it in places the API wants a <cite>BaseDecoder</cite> object.</p>
<p>Exceptions raised from <cite>BaseDecoder</cite> instances are ignored.</p>
<dl class="py method">
<dt id="palace.BaseDecoder.channel_config">
<em class="property">abstract property </em><code class="sig-name descname">channel_config</code><a class="headerlink" href="#palace.BaseDecoder.channel_config" title="Permalink to this definition"></a></dt>
<dd><p>Channel configuration of the audio being decoded.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.BaseDecoder.frequency">
<em class="property">abstract property </em><code class="sig-name descname">frequency</code><a class="headerlink" href="#palace.BaseDecoder.frequency" title="Permalink to this definition"></a></dt>
<dd><p>Sample frequency, in hertz, of the audio being decoded.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.BaseDecoder.length">
<em class="property">abstract property </em><code class="sig-name descname">length</code><a class="headerlink" href="#palace.BaseDecoder.length" title="Permalink to this definition"></a></dt>
<dd><p>Length of audio in sample frames, falling-back to 0.</p>
<p class="rubric">Notes</p>
<p>Zero-length decoders may not be used to load a <cite>Buffer</cite>.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.BaseDecoder.loop_points">
<em class="property">abstract property </em><code class="sig-name descname">loop_points</code><a class="headerlink" href="#palace.BaseDecoder.loop_points" title="Permalink to this definition"></a></dt>
<dd><p>Loop points in sample frames.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><ul class="simple">
<li><p><strong>start</strong> (<em>int</em>) Inclusive starting loop point.</p></li>
<li><p><strong>end</strong> (<em>int</em>) Exclusive starting loop point.</p></li>
</ul>
</p>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>If <cite>start &gt;= end</cite>, all available samples are included
in the loop.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.BaseDecoder.read">
<em class="property">abstract </em><code class="sig-name descname">read</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">count</span><span class="p">:</span> <span class="n">int</span></em><span class="sig-paren">)</span> &#x2192; bytes<a class="headerlink" href="#palace.BaseDecoder.read" title="Permalink to this definition"></a></dt>
<dd><p>Decode and return <cite>count</cite> sample frames.</p>
<p>If less than the requested count samples is returned,
the end of the audio has been reached.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.BaseDecoder.sample_type">
<em class="property">abstract property </em><code class="sig-name descname">sample_type</code><a class="headerlink" href="#palace.BaseDecoder.sample_type" title="Permalink to this definition"></a></dt>
<dd><p>Sample type of the audio being decoded.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.BaseDecoder.seek">
<em class="property">abstract </em><code class="sig-name descname">seek</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">pos</span><span class="p">:</span> <span class="n">int</span></em><span class="sig-paren">)</span> &#x2192; bool<a class="headerlink" href="#palace.BaseDecoder.seek" title="Permalink to this definition"></a></dt>
<dd><p>Seek to pos, specified in sample frames.</p>
<p>Return if the seek was successful.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="miscellaneous">
<h2>Miscellaneous<a class="headerlink" href="#miscellaneous" title="Permalink to this headline"></a></h2>
<dl class="py data">
<dt id="palace.sample_types">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">sample_types</code><em class="property">: Tuple<span class="p">[</span>str<span class="p">, </span><span class="p"></span><span class="p">]</span></em><a class="headerlink" href="#palace.sample_types" title="Permalink to this definition"></a></dt>
<dd><p>Names of available sample types.</p>
</dd></dl>
<dl class="py data">
<dt id="palace.channel_configs">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">channel_configs</code><em class="property">: Tuple<span class="p">[</span>str<span class="p">, </span><span class="p"></span><span class="p">]</span></em><a class="headerlink" href="#palace.channel_configs" title="Permalink to this definition"></a></dt>
<dd><p>Names of available channel configurations.</p>
</dd></dl>
<dl class="py function">
<dt id="palace.sample_size">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">sample_size</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">length</span><span class="p">:</span> <span class="n">int</span></em>, <em class="sig-param"><span class="n">channel_config</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">sample_type</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span> &#x2192; int<a class="headerlink" href="#palace.sample_size" title="Permalink to this definition"></a></dt>
<dd><p>Return the size of the given number of sample frames.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ValueError</strong> If either channel_config or sample_type is invalid.</p></li>
<li><p><strong>RuntimeError</strong> If the byte size result too large.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="palace.sample_length">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">sample_length</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">size</span><span class="p">:</span> <span class="n">int</span></em>, <em class="sig-param"><span class="n">channel_config</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">sample_type</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span> &#x2192; int<a class="headerlink" href="#palace.sample_length" title="Permalink to this definition"></a></dt>
<dd><p>Return the number of frames stored in the given byte size.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>ValueError</strong> If either channel_config or sample_type is invalid.</p>
</dd>
</dl>
</dd></dl>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="effect.html" title="Previous document">Environmental Effects</a>
</li>
<li>
<a href="file-io.html" title="Next document">File I/O Interface</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/reference/decoder.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,330 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Audio Devices &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Audio Library Contexts" href="context.html" />
<link rel="prev" title="Reference" href="index.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Reference</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">Audio Devices</a></li>
<li class="toctree-l2"><a class="reference internal" href="context.html">Audio Library Contexts</a></li>
<li class="toctree-l2"><a class="reference internal" href="buffer.html">Resource Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html">Sources &amp; Source Groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="effect.html">Environmental Effects</a></li>
<li class="toctree-l2"><a class="reference internal" href="decoder.html">Audio Streams</a></li>
<li class="toctree-l2"><a class="reference internal" href="file-io.html">File I/O Interface</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="index.html" title="Previous document">Reference</a>
</li>
<li>
<a href="context.html" title="Next document">Audio Library Contexts</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="audio-devices">
<h1>Audio Devices<a class="headerlink" href="#audio-devices" title="Permalink to this headline"></a></h1>
<div class="section" id="device-dependent-utilities">
<h2>Device-Dependent Utilities<a class="headerlink" href="#device-dependent-utilities" title="Permalink to this headline"></a></h2>
<dl class="py class">
<dt id="palace.Device">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">Device</code><a class="headerlink" href="#palace.Device" title="Permalink to this definition"></a></dt>
<dd><p>Audio mix output, via either a system stream or a hardware port.</p>
<p>This can be used as a context manager that calls <cite>close</cite> upon
completion of the block, even if an error occurs.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em>) The name of the playback device.</p></li>
<li><p><strong>fallback</strong> (<em>Iterable</em><em>[</em><em>str</em><em>]</em><em>, </em><em>optional</em>) Device names to fallback to, default to an empty tuple.</p></li>
</ul>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>RuntimeError</strong> If device creation fails.</p>
</dd>
<dt class="field-odd">Warns</dt>
<dd class="field-odd"><p><strong>RuntimeWarning</strong> Before each fallback.</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#palace.device_names" title="palace.device_names"><code class="xref py py-class docutils literal notranslate"><span class="pre">device_names</span></code></a></dt><dd><p>Available device names</p>
</dd>
</dl>
</div>
<dl class="py method">
<dt id="palace.Device.alc_version">
<em class="property">property </em><code class="sig-name descname">alc_version</code><a class="headerlink" href="#palace.Device.alc_version" title="Permalink to this definition"></a></dt>
<dd><p>ALC version supported by this device.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.basic_name">
<em class="property">property </em><code class="sig-name descname">basic_name</code><a class="headerlink" href="#palace.Device.basic_name" title="Permalink to this definition"></a></dt>
<dd><p>Basic name of the device.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.clock_time">
<em class="property">property </em><code class="sig-name descname">clock_time</code><a class="headerlink" href="#palace.Device.clock_time" title="Permalink to this definition"></a></dt>
<dd><p>Current clock time for the device.</p>
<p class="rubric">Notes</p>
<p>This starts relative to the device being opened, and does not
increment while there are no contexts nor while processing
is paused. Currently, this may not exactly match the rate
that sources play at. In the future it may utilize an OpenAL
extension to retrieve the audio devices real clock.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.close">
<code class="sig-name descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Device.close" title="Permalink to this definition"></a></dt>
<dd><p>Close and free the device.</p>
<p>All previously-created contexts must first be destroyed.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.current_hrtf">
<em class="property">property </em><code class="sig-name descname">current_hrtf</code><a class="headerlink" href="#palace.Device.current_hrtf" title="Permalink to this definition"></a></dt>
<dd><p>Name of the HRTF currently being used by this device.</p>
<p>If HRTF is not currently enabled, this will be <cite>None</cite>.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.efx_version">
<em class="property">property </em><code class="sig-name descname">efx_version</code><a class="headerlink" href="#palace.Device.efx_version" title="Permalink to this definition"></a></dt>
<dd><p>EFX version supported by this device.</p>
<p>If <cite>ALC_EXT_EFX</cite> extension is unsupported, this will be (0, 0).</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.frequency">
<em class="property">property </em><code class="sig-name descname">frequency</code><a class="headerlink" href="#palace.Device.frequency" title="Permalink to this definition"></a></dt>
<dd><p>Playback frequency in hertz.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.hrtf_enabled">
<em class="property">property </em><code class="sig-name descname">hrtf_enabled</code><a class="headerlink" href="#palace.Device.hrtf_enabled" title="Permalink to this definition"></a></dt>
<dd><p>Whether HRTF is enabled on the device.</p>
<p>If <cite>ALC_SOFT_HRTF</cite> extension is unavailable,
this will return False although there could still be
HRTF applied at a lower hardware level.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.hrtf_names">
<em class="property">property </em><code class="sig-name descname">hrtf_names</code><a class="headerlink" href="#palace.Device.hrtf_names" title="Permalink to this definition"></a></dt>
<dd><p>List of available HRTF names.</p>
<p>The order is retained from OpenAL, such that the index of
a given name is the ID to use with <cite>ALC_HRTF_ID_SOFT</cite>.</p>
<p>If <cite>ALC_SOFT_HRTF</cite> extension is unavailable,
this will be an empty list.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.max_auxiliary_sends">
<em class="property">property </em><code class="sig-name descname">max_auxiliary_sends</code><a class="headerlink" href="#palace.Device.max_auxiliary_sends" title="Permalink to this definition"></a></dt>
<dd><p>Maximum number of auxiliary source sends.</p>
<p>If <cite>ALC_EXT_EFX</cite> is unsupported, this will be 0.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.name">
<em class="property">property </em><code class="sig-name descname">name</code><a class="headerlink" href="#palace.Device.name" title="Permalink to this definition"></a></dt>
<dd><p>Name of the device.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.pause_dsp">
<code class="sig-name descname">pause_dsp</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Device.pause_dsp" title="Permalink to this definition"></a></dt>
<dd><p>Pause device processing and stop contexts updates.</p>
<p>Multiple calls are allowed but it is not reference counted,
so the device will resume after one <cite>resume_dsp</cite> call.</p>
<p>This requires <cite>ALC_SOFT_pause_device</cite> extension.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.query_extension">
<code class="sig-name descname">query_extension</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span> &#x2192; bool<a class="headerlink" href="#palace.Device.query_extension" title="Permalink to this definition"></a></dt>
<dd><p>Return if an ALC extension exists on this device.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#palace.query_extension" title="palace.query_extension"><code class="xref py py-meth docutils literal notranslate"><span class="pre">query_extension()</span></code></a></dt><dd><p>Query non-device-specific ALC extension</p>
</dd>
</dl>
</div>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.reset">
<code class="sig-name descname">reset</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">attrs</span><span class="p">:</span> <span class="n">Dict<span class="p">[</span>int<span class="p">, </span>int<span class="p">]</span></span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Device.reset" title="Permalink to this definition"></a></dt>
<dd><p>Reset the device, using the specified attributes.</p>
<p>If <cite>ALC_SOFT_HRTF</cite> extension is unavailable,
this will be a no-op.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Device.resume_dsp">
<code class="sig-name descname">resume_dsp</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Device.resume_dsp" title="Permalink to this definition"></a></dt>
<dd><p>Resume device processing and restart contexts updates.</p>
<p>Multiple calls are allowed and will no-op.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="device-independent-utilities">
<h2>Device-Independent Utilities<a class="headerlink" href="#device-independent-utilities" title="Permalink to this headline"></a></h2>
<dl class="py data">
<dt id="palace.device_names">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">device_names</code><em class="property">: DeviceNames</em><a class="headerlink" href="#palace.device_names" title="Permalink to this definition"></a></dt>
<dd><p>Read-only namespace of device names by category (<code class="docutils literal notranslate"><span class="pre">basic</span></code>, <code class="docutils literal notranslate"><span class="pre">full</span></code> and
<code class="docutils literal notranslate"><span class="pre">capture</span></code>), as tuples of strings whose first item being the default.</p>
</dd></dl>
<dl class="py function">
<dt id="palace.query_extension">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">query_extension</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span> &#x2192; bool<a class="headerlink" href="#palace.query_extension" title="Permalink to this definition"></a></dt>
<dd><p>Return if a non-device-specific ALC extension exists.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#palace.Device.query_extension" title="palace.Device.query_extension"><code class="xref py py-func docutils literal notranslate"><span class="pre">Device.query_extension()</span></code></a></dt><dd><p>Query ALC extension on a device</p>
</dd>
</dl>
</div>
</dd></dl>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="index.html" title="Previous document">Reference</a>
</li>
<li>
<a href="context.html" title="Next document">Audio Library Contexts</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/reference/device.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,451 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Environmental Effects &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Audio Streams" href="decoder.html" />
<link rel="prev" title="Sources &amp; Source Groups" href="source.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="device.html">Audio Devices</a></li>
<li class="toctree-l2"><a class="reference internal" href="context.html">Audio Library Contexts</a></li>
<li class="toctree-l2"><a class="reference internal" href="buffer.html">Resource Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html">Sources &amp; Source Groups</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Environmental Effects</a></li>
<li class="toctree-l2"><a class="reference internal" href="decoder.html">Audio Streams</a></li>
<li class="toctree-l2"><a class="reference internal" href="file-io.html">File I/O Interface</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="source.html" title="Previous document">Sources &amp; Source Groups</a>
</li>
<li>
<a href="decoder.html" title="Next document">Audio Streams</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="environmental-effects">
<h1>Environmental Effects<a class="headerlink" href="#environmental-effects" title="Permalink to this headline"></a></h1>
<p>For the sake of brevity, we only document the constraints of each effects
properties. Further details can be found at OpenALs <a class="reference external" href="https://kcat.strangesoft.net/misc-downloads/Effects%20Extension%20Guide.pdf">Effect Extension Guide</a>
which specifies the purpose and usage of each value.</p>
<div class="section" id="base-effect">
<h2>Base Effect<a class="headerlink" href="#base-effect" title="Permalink to this headline"></a></h2>
<dl class="py class">
<dt id="palace.BaseEffect">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">BaseEffect</code><a class="headerlink" href="#palace.BaseEffect" title="Permalink to this definition"></a></dt>
<dd><p>Base effect processor.</p>
<p>Instances of this class has no effect (pun intended).</p>
<p>It takes the output mix of zero or more sources,
applies DSP for the desired effect, then adds to the output mix.</p>
<p>This can be used as a context manager that calls <cite>destroy</cite>
upon completion of the block, even if an error occurs.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>context</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="context.html#palace.Context" title="palace.Context"><em>Context</em></a><em>]</em><em>, </em><em>optional</em>) The context from which the effect is to be created.
By default <cite>current_context()</cite> is used.</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>RuntimeError</strong> If there is neither any context specified nor current.</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#palace.ReverbEffect" title="palace.ReverbEffect"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReverbEffect</span></code></a></dt><dd><p>Environmental reverberation effect</p>
</dd>
<dt><a class="reference internal" href="#palace.ChorusEffect" title="palace.ChorusEffect"><code class="xref py py-class docutils literal notranslate"><span class="pre">ChorusEffect</span></code></a></dt><dd><p>Chorus effect</p>
</dd>
</dl>
</div>
<dl class="py method">
<dt id="palace.BaseEffect.destroy">
<code class="sig-name descname">destroy</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.BaseEffect.destroy" title="Permalink to this definition"></a></dt>
<dd><p>Destroy the effect slot, returning it to the system.</p>
<p>If the effect slot is currently set on a source send,
it will be removed first.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.BaseEffect.slot_gain">
<em class="property">property </em><code class="sig-name descname">slot_gain</code><a class="headerlink" href="#palace.BaseEffect.slot_gain" title="Permalink to this definition"></a></dt>
<dd><p>Gain of the effect slot.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.BaseEffect.source_sends">
<em class="property">property </em><code class="sig-name descname">source_sends</code><a class="headerlink" href="#palace.BaseEffect.source_sends" title="Permalink to this definition"></a></dt>
<dd><p>List of sources using this effect and their pairing sends.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.BaseEffect.use_count">
<em class="property">property </em><code class="sig-name descname">use_count</code><a class="headerlink" href="#palace.BaseEffect.use_count" title="Permalink to this definition"></a></dt>
<dd><p>Number of source sends the effect slot is used by.</p>
<p>This is equivalent to calling <cite>len(self.source_sends)</cite>.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="chorus-effect">
<h2>Chorus Effect<a class="headerlink" href="#chorus-effect" title="Permalink to this headline"></a></h2>
<dl class="py class">
<dt id="palace.ChorusEffect">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">ChorusEffect</code><a class="headerlink" href="#palace.ChorusEffect" title="Permalink to this definition"></a></dt>
<dd><p>Chorus effect.</p>
<p>The chorus effect essentially replays the input audio accompanied
by another slightly delayed version of the signal, creating
a “doubling” effect. This was originally intended to emulate
the effect of several musicians playing the same notes
simultaneously, to create a thicker, more satisfying sound.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>waveform</strong> (<em>str</em>) Either sine or triangle.</p></li>
<li><p><strong>phase</strong> (<em>int</em>) From -180 to 180.</p></li>
<li><p><strong>depth</strong> (<em>float</em>) From 0.0 to 1.0.</p></li>
<li><p><strong>feedback</strong> (<em>float</em>) From -1.0 to 1.0.</p></li>
<li><p><strong>delay</strong> (<em>float</em>) From 0.0 to 0.016.</p></li>
<li><p><strong>context</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="context.html#palace.Context" title="palace.Context"><em>Context</em></a><em>]</em><em>, </em><em>optional</em>) The context from which the effect is to be created.
By default <cite>current_context()</cite> is used.</p></li>
</ul>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>RuntimeError</strong> If there is neither any context specified nor current.</p>
</dd>
</dl>
<dl class="py attribute">
<dt id="palace.ChorusEffect.delay">
<code class="sig-name descname">delay</code><a class="headerlink" href="#palace.ChorusEffect.delay" title="Permalink to this definition"></a></dt>
<dd><p>Delay, from 0.0 to 0.016.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ChorusEffect.depth">
<code class="sig-name descname">depth</code><a class="headerlink" href="#palace.ChorusEffect.depth" title="Permalink to this definition"></a></dt>
<dd><p>Depth, from 0.0 to 1.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ChorusEffect.feedback">
<code class="sig-name descname">feedback</code><a class="headerlink" href="#palace.ChorusEffect.feedback" title="Permalink to this definition"></a></dt>
<dd><p>Feedback, from -1.0 to 1.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ChorusEffect.phase">
<code class="sig-name descname">phase</code><a class="headerlink" href="#palace.ChorusEffect.phase" title="Permalink to this definition"></a></dt>
<dd><p>Phase, from -180 to 180.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ChorusEffect.waveform">
<code class="sig-name descname">waveform</code><a class="headerlink" href="#palace.ChorusEffect.waveform" title="Permalink to this definition"></a></dt>
<dd><p>Waveform, either sine or triangle.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="reverb-effect">
<h2>Reverb Effect<a class="headerlink" href="#reverb-effect" title="Permalink to this headline"></a></h2>
<dl class="py data">
<dt id="palace.reverb_preset_names">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">reverb_preset_names</code><em class="property">: Tuple<span class="p">[</span>str<span class="p">, </span><span class="p"></span><span class="p">]</span></em><a class="headerlink" href="#palace.reverb_preset_names" title="Permalink to this definition"></a></dt>
<dd><p>Names of predefined reverb effect presets in lexicographical order.</p>
</dd></dl>
<dl class="py class">
<dt id="palace.ReverbEffect">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">ReverbEffect</code><a class="headerlink" href="#palace.ReverbEffect" title="Permalink to this definition"></a></dt>
<dd><p>Environmental reverberation effect.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>preset</strong> (<em>str</em><em>, </em><em>optional</em>) The initial preset to start with, falling back to GENERIC.</p></li>
<li><p><strong>context</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="context.html#palace.Context" title="palace.Context"><em>Context</em></a><em>]</em><em>, </em><em>optional</em>) The context from which the effect is to be created.
By default <cite>current_context()</cite> is used.</p></li>
</ul>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><ul class="simple">
<li><p><strong>ValueError</strong> If the specified preset cannot be found in <cite>reverb_preset_names</cite>.</p></li>
<li><p><strong>RuntimeError</strong> If there is neither any context specified nor current.</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.air_absorption_gain_hf">
<code class="sig-name descname">air_absorption_gain_hf</code><a class="headerlink" href="#palace.ReverbEffect.air_absorption_gain_hf" title="Permalink to this definition"></a></dt>
<dd><p>High frequency air absorption gain, from 0.892 to 1.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.decay_hf_limit">
<code class="sig-name descname">decay_hf_limit</code><a class="headerlink" href="#palace.ReverbEffect.decay_hf_limit" title="Permalink to this definition"></a></dt>
<dd><p>Whether to limit high frequency decay.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.decay_hf_ratio">
<code class="sig-name descname">decay_hf_ratio</code><a class="headerlink" href="#palace.ReverbEffect.decay_hf_ratio" title="Permalink to this definition"></a></dt>
<dd><p>High frequency decay ratio, from 0.1 to 20.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.decay_lf_ratio">
<code class="sig-name descname">decay_lf_ratio</code><a class="headerlink" href="#palace.ReverbEffect.decay_lf_ratio" title="Permalink to this definition"></a></dt>
<dd><p>Low frequency decay ratio, from 0.1 to 20.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.decay_time">
<code class="sig-name descname">decay_time</code><a class="headerlink" href="#palace.ReverbEffect.decay_time" title="Permalink to this definition"></a></dt>
<dd><p>Decay time, from 0.1 to 20.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.density">
<code class="sig-name descname">density</code><a class="headerlink" href="#palace.ReverbEffect.density" title="Permalink to this definition"></a></dt>
<dd><p>Density, from 0.0 to 1.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.diffusion">
<code class="sig-name descname">diffusion</code><a class="headerlink" href="#palace.ReverbEffect.diffusion" title="Permalink to this definition"></a></dt>
<dd><p>Diffusion, from 0.0 to 1.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.echo_depth">
<code class="sig-name descname">echo_depth</code><a class="headerlink" href="#palace.ReverbEffect.echo_depth" title="Permalink to this definition"></a></dt>
<dd><p>Echo depth, from 0.0 to 1.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.echo_time">
<code class="sig-name descname">echo_time</code><a class="headerlink" href="#palace.ReverbEffect.echo_time" title="Permalink to this definition"></a></dt>
<dd><p>Echo time, from 0.075 to 0.25.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.gain">
<code class="sig-name descname">gain</code><a class="headerlink" href="#palace.ReverbEffect.gain" title="Permalink to this definition"></a></dt>
<dd><p>Gain, from 0.0 to 1.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.gain_hf">
<code class="sig-name descname">gain_hf</code><a class="headerlink" href="#palace.ReverbEffect.gain_hf" title="Permalink to this definition"></a></dt>
<dd><p>High frequency gain, from 0.0 to 1.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.gain_lf">
<code class="sig-name descname">gain_lf</code><a class="headerlink" href="#palace.ReverbEffect.gain_lf" title="Permalink to this definition"></a></dt>
<dd><p>Low frequency gain, from 0.0 to 1.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.hf_reference">
<code class="sig-name descname">hf_reference</code><a class="headerlink" href="#palace.ReverbEffect.hf_reference" title="Permalink to this definition"></a></dt>
<dd><p>High frequency reference, from 1000.0 to 20000.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.late_reverb_delay">
<code class="sig-name descname">late_reverb_delay</code><a class="headerlink" href="#palace.ReverbEffect.late_reverb_delay" title="Permalink to this definition"></a></dt>
<dd><p>Late reverb delay, from 0.0 to 0.1.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.late_reverb_gain">
<code class="sig-name descname">late_reverb_gain</code><a class="headerlink" href="#palace.ReverbEffect.late_reverb_gain" title="Permalink to this definition"></a></dt>
<dd><p>Late reverb gain, from 0.0 to 10.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.late_reverb_pan">
<code class="sig-name descname">late_reverb_pan</code><a class="headerlink" href="#palace.ReverbEffect.late_reverb_pan" title="Permalink to this definition"></a></dt>
<dd><p>Late reverb as 3D vector of magnitude between 0 and 1.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.lf_reference">
<code class="sig-name descname">lf_reference</code><a class="headerlink" href="#palace.ReverbEffect.lf_reference" title="Permalink to this definition"></a></dt>
<dd><p>Low frequency reference, from 20.0 to 1000.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.modulation_depth">
<code class="sig-name descname">modulation_depth</code><a class="headerlink" href="#palace.ReverbEffect.modulation_depth" title="Permalink to this definition"></a></dt>
<dd><p>Modulation depth, from 0.0 to 1.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.modulation_time">
<code class="sig-name descname">modulation_time</code><a class="headerlink" href="#palace.ReverbEffect.modulation_time" title="Permalink to this definition"></a></dt>
<dd><p>Modulation time, from 0.004 to 4.0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.reflections_delay">
<code class="sig-name descname">reflections_delay</code><a class="headerlink" href="#palace.ReverbEffect.reflections_delay" title="Permalink to this definition"></a></dt>
<dd><p>Reflections delay, from 0.0 to 0.3.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.reflections_gain">
<code class="sig-name descname">reflections_gain</code><a class="headerlink" href="#palace.ReverbEffect.reflections_gain" title="Permalink to this definition"></a></dt>
<dd><p>Reflections gain, from 0.0 to 3.16.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.reflections_pan">
<code class="sig-name descname">reflections_pan</code><a class="headerlink" href="#palace.ReverbEffect.reflections_pan" title="Permalink to this definition"></a></dt>
<dd><p>Reflections as 3D vector of magnitude between 0 and 1.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.ReverbEffect.room_rolloff_factor">
<code class="sig-name descname">room_rolloff_factor</code><a class="headerlink" href="#palace.ReverbEffect.room_rolloff_factor" title="Permalink to this definition"></a></dt>
<dd><p>Room rolloff factor, from 0.0 to 10.0.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.ReverbEffect.send_auto">
<em class="property">property </em><code class="sig-name descname">send_auto</code><a class="headerlink" href="#palace.ReverbEffect.send_auto" title="Permalink to this definition"></a></dt>
<dd><p>Whether to automatically adjust send slot gains.</p>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="source.html" title="Previous document">Sources &amp; Source Groups</a>
</li>
<li>
<a href="decoder.html" title="Next document">Audio Streams</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/reference/effect.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,211 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>File I/O Interface &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Design Principles" href="../design.html" />
<link rel="prev" title="Audio Streams" href="decoder.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="device.html">Audio Devices</a></li>
<li class="toctree-l2"><a class="reference internal" href="context.html">Audio Library Contexts</a></li>
<li class="toctree-l2"><a class="reference internal" href="buffer.html">Resource Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html">Sources &amp; Source Groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="effect.html">Environmental Effects</a></li>
<li class="toctree-l2"><a class="reference internal" href="decoder.html">Audio Streams</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">File I/O Interface</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="decoder.html" title="Previous document">Audio Streams</a>
</li>
<li>
<a href="../design.html" title="Next document">Design Principles</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="file-i-o-interface">
<h1>File I/O Interface<a class="headerlink" href="#file-i-o-interface" title="Permalink to this headline"></a></h1>
<dl class="py function">
<dt id="palace.current_fileio">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">current_fileio</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; Optional<span class="p">[</span>Callable<span class="p">[</span><span class="p">[</span>str<span class="p">]</span><span class="p">, </span><a class="reference internal" href="#palace.FileIO" title="palace.FileIO">palace.FileIO</a><span class="p">]</span><span class="p">]</span><a class="headerlink" href="#palace.current_fileio" title="Permalink to this definition"></a></dt>
<dd><p>Return the file I/O factory currently in used by audio decoders.</p>
<p>If the default is being used, return <cite>None</cite>.</p>
</dd></dl>
<dl class="py function">
<dt id="palace.use_fileio">
<code class="sig-prename descclassname">palace.</code><code class="sig-name descname">use_fileio</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">factory</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span>Callable<span class="p">[</span><span class="p">[</span>str<span class="p">]</span><span class="p">, </span><a class="reference internal" href="#palace.FileIO" title="palace.FileIO">FileIO</a><span class="p">]</span><span class="p">]</span></span></em>, <em class="sig-param"><span class="n">buffer_size</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">8192</span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.use_fileio" title="Permalink to this definition"></a></dt>
<dd><p>Set the file I/O factory instance to be used by audio decoders.</p>
<p>If <cite>factory=None</cite> is provided, revert to the default.</p>
</dd></dl>
<dl class="py class">
<dt id="palace.FileIO">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">FileIO</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwds</span></em><span class="sig-paren">)</span><a class="headerlink" href="#palace.FileIO" title="Permalink to this definition"></a></dt>
<dd><p>File I/O protocol.</p>
<p>This static duck type defines methods required to be used by
palace decoders. Despite its name, a <cite>FileIO</cite> is not necessarily
created from a file, but any seekable finite input stream.</p>
<p>Many classes defined in the standard library module <cite>io</cite>
are compatible with this protocol.</p>
<p class="rubric">Notes</p>
<p>Since PEP 544 is only implemented in Python 3.8+, type checking
for this on earlier Python version might not work as expected.</p>
<dl class="py method">
<dt id="palace.FileIO.close">
<em class="property">abstract </em><code class="sig-name descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.FileIO.close" title="Permalink to this definition"></a></dt>
<dd><p>Close the file.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.FileIO.read">
<em class="property">abstract </em><code class="sig-name descname">read</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">size</span><span class="p">:</span> <span class="n">int</span></em><span class="sig-paren">)</span> &#x2192; bytes<a class="headerlink" href="#palace.FileIO.read" title="Permalink to this definition"></a></dt>
<dd><p>Read at most size bytes, returned as bytes.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.FileIO.seek">
<em class="property">abstract </em><code class="sig-name descname">seek</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">offset</span><span class="p">:</span> <span class="n">int</span></em>, <em class="sig-param"><span class="n">whence</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">0</span></em><span class="sig-paren">)</span> &#x2192; int<a class="headerlink" href="#palace.FileIO.seek" title="Permalink to this definition"></a></dt>
<dd><p>Move to new file position and return the file position.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>offset</strong> (<em>int</em>) A byte count.</p></li>
<li><p><strong>whence</strong> (<em>int</em><em>, </em><em>optional</em>) Either 0 (default, move relative to start of file),
1 (move relative to current position)
or 2 (move relative to end of file).</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="decoder.html" title="Previous document">Audio Streams</a>
</li>
<li>
<a href="../design.html" title="Next document">Design Principles</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/reference/file-io.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,194 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Reference &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Audio Devices" href="device.html" />
<link rel="prev" title="Source Manipulation" href="../tutorial/source.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Reference</a><ul>
<li class="toctree-l2"><a class="reference internal" href="device.html">Audio Devices</a></li>
<li class="toctree-l2"><a class="reference internal" href="context.html">Audio Library Contexts</a></li>
<li class="toctree-l2"><a class="reference internal" href="buffer.html">Resource Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html">Sources &amp; Source Groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="effect.html">Environmental Effects</a></li>
<li class="toctree-l2"><a class="reference internal" href="decoder.html">Audio Streams</a></li>
<li class="toctree-l2"><a class="reference internal" href="file-io.html">File I/O Interface</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="../tutorial/source.html" title="Previous document">Source Manipulation</a>
</li>
<li>
<a href="device.html" title="Next document">Audio Devices</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="reference">
<h1>Reference<a class="headerlink" href="#reference" title="Permalink to this headline"></a></h1>
<p>API reference is divided into the following sections:</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="device.html">Audio Devices</a><ul>
<li class="toctree-l2"><a class="reference internal" href="device.html#device-dependent-utilities">Device-Dependent Utilities</a></li>
<li class="toctree-l2"><a class="reference internal" href="device.html#device-independent-utilities">Device-Independent Utilities</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="context.html">Audio Library Contexts</a><ul>
<li class="toctree-l2"><a class="reference internal" href="context.html#context-and-auxiliary-classes">Context and Auxiliary Classes</a></li>
<li class="toctree-l2"><a class="reference internal" href="context.html#using-contexts">Using Contexts</a></li>
<li class="toctree-l2"><a class="reference internal" href="context.html#context-creation-attributes">Context Creation Attributes</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="buffer.html">Resource Caching</a><ul>
<li class="toctree-l2"><a class="reference internal" href="buffer.html#audio-buffers">Audio Buffers</a></li>
<li class="toctree-l2"><a class="reference internal" href="buffer.html#loading-freeing-in-batch">Loading &amp; Freeing in Batch</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="source.html">Sources &amp; Source Groups</a><ul>
<li class="toctree-l2"><a class="reference internal" href="source.html#sources">Sources</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html#source-groups">Source Groups</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="effect.html">Environmental Effects</a><ul>
<li class="toctree-l2"><a class="reference internal" href="effect.html#base-effect">Base Effect</a></li>
<li class="toctree-l2"><a class="reference internal" href="effect.html#chorus-effect">Chorus Effect</a></li>
<li class="toctree-l2"><a class="reference internal" href="effect.html#reverb-effect">Reverb Effect</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="decoder.html">Audio Streams</a><ul>
<li class="toctree-l2"><a class="reference internal" href="decoder.html#builtin-decoders">Builtin Decoders</a></li>
<li class="toctree-l2"><a class="reference internal" href="decoder.html#decoder-interface">Decoder Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="decoder.html#miscellaneous">Miscellaneous</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="file-io.html">File I/O Interface</a></li>
</ul>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="../tutorial/source.html" title="Previous document">Source Manipulation</a>
</li>
<li>
<a href="device.html" title="Next document">Audio Devices</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/reference/index.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,673 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sources &amp; Source Groups &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Environmental Effects" href="effect.html" />
<link rel="prev" title="Resource Caching" href="buffer.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="device.html">Audio Devices</a></li>
<li class="toctree-l2"><a class="reference internal" href="context.html">Audio Library Contexts</a></li>
<li class="toctree-l2"><a class="reference internal" href="buffer.html">Resource Caching</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Sources &amp; Source Groups</a></li>
<li class="toctree-l2"><a class="reference internal" href="effect.html">Environmental Effects</a></li>
<li class="toctree-l2"><a class="reference internal" href="decoder.html">Audio Streams</a></li>
<li class="toctree-l2"><a class="reference internal" href="file-io.html">File I/O Interface</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="buffer.html" title="Previous document">Resource Caching</a>
</li>
<li>
<a href="effect.html" title="Next document">Environmental Effects</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="sources-source-groups">
<h1>Sources &amp; Source Groups<a class="headerlink" href="#sources-source-groups" title="Permalink to this headline"></a></h1>
<div class="section" id="sources">
<h2>Sources<a class="headerlink" href="#sources" title="Permalink to this headline"></a></h2>
<dl class="py class">
<dt id="palace.Source">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">Source</code><a class="headerlink" href="#palace.Source" title="Permalink to this definition"></a></dt>
<dd><p>Sound source for playing audio.</p>
<p>There is no practical limit to the number of sources one may create.</p>
<p>When the source is no longer needed, <cite>destroy</cite> must be called,
unless the context manager is used, which guarantees the sources
destructioni upon completion of the block, even if an error occurs.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>context</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="context.html#palace.Context" title="palace.Context"><em>Context</em></a><em>]</em><em>, </em><em>optional</em>) The context from which the source is to be created.
By default <cite>current_context()</cite> is used.</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>RuntimeError</strong> If there is neither any context specified nor current.</p>
</dd>
</dl>
<dl class="py attribute">
<dt id="palace.Source.air_absorption_factor">
<code class="sig-name descname">air_absorption_factor</code><a class="headerlink" href="#palace.Source.air_absorption_factor" title="Permalink to this definition"></a></dt>
<dd><p>Multiplier for atmospheric high-frequency absorption</p>
<p>Its value ranging from 0 to 10. A factor of 1 results in
a nominal -0.05 dB per meter, with higher values simulating
foggy air and lower values simulating dryer air; default to 0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.cone_angles">
<code class="sig-name descname">cone_angles</code><a class="headerlink" href="#palace.Source.cone_angles" title="Permalink to this definition"></a></dt>
<dd><p>Cone inner and outer angles in degrees.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><ul class="simple">
<li><p><strong>inner</strong> (<em>float</em>) The area within which the listener will hear the source
without extra attenuation, default to 360.</p></li>
<li><p><strong>outer</strong> (<em>float</em>) The area outside of which the listener will hear the source
attenuated according to <cite>outer_cone_gains</cite>, default to 360.</p></li>
</ul>
</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> If set to a value where <cite>inner</cite> is greater than <cite>outer</cite>
or either of them is outside of the [0, 360] interval.</p>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>The areas follow the facing direction, so for example
an inner angle of 180 means the entire front face of
the source is in the inner cone.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.destroy">
<code class="sig-name descname">destroy</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Source.destroy" title="Permalink to this definition"></a></dt>
<dd><p>Destroy the source, stop playback and release resources.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.distance_range">
<code class="sig-name descname">distance_range</code><a class="headerlink" href="#palace.Source.distance_range" title="Permalink to this definition"></a></dt>
<dd><p>Reference and maximum distance for current distance model.</p>
<p>For Clamped distance models, the sources calculated
distance is clamped to the specified range before applying
distance-related attenuation.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><ul class="simple">
<li><p><strong>refdist</strong> (<em>float</em>) The distance at which the sources volume will not have
any extra attenuation (an effective gain multiplier of 1),
default to 0.</p></li>
<li><p><strong>maxdist</strong> (<em>float</em>) The maximum distance, default to FLT_MAX, which is the
maximum value of a single-precision floating-point variable
(2**128 - 2**104).</p></li>
</ul>
</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> If set to a value where <cite>refdist</cite> is greater than <cite>maxdist</cite>
or either of them is outside of the [0, FLT_MAX] interval.</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.doppler_factor">
<code class="sig-name descname">doppler_factor</code><a class="headerlink" href="#palace.Source.doppler_factor" title="Permalink to this definition"></a></dt>
<dd><p>The doppler factor for the doppler effects pitch shift.</p>
<p>This effectively scales the source and listener velocities
for the doppler calculation.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>ValueError</strong> If set to a value outside of the [0, 1] interval.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.fade_out_to_stop">
<code class="sig-name descname">fade_out_to_stop</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">gain</span><span class="p">:</span> <span class="n">float</span></em>, <em class="sig-param"><span class="n">ms</span><span class="p">:</span> <span class="n">int</span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Source.fade_out_to_stop" title="Permalink to this definition"></a></dt>
<dd><p>Fade the source to <cite>gain</cite> over <cite>ms</cite> milliseconds.</p>
<p><cite>gain</cite> is in addition to the base gain and must be within
the [0, 1] interval. <cite>ms</cite> must be positive.</p>
<p>The fading is logarithmic. As a result, the initial drop-off
may happen faster than expected but the fading is more
perceptually consistant over the given duration. It will take
just as much time to go from -6 dB to -12 dB as it will to go
from -40 dB to -46 dB, for example.</p>
<p>Fading is updated during calls to <cite>Context.update</cite>,
which should be called regularly (30 to 50 times per second)
for the fading to be smooth.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.filter">
<em class="property">property </em><code class="sig-name descname">filter</code><a class="headerlink" href="#palace.Source.filter" title="Permalink to this definition"></a></dt>
<dd><p>Linear gains on the direct path signal, clamped to [0, 1].</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>gain</strong> (<em>float</em>) Linear gain applying to all frequencies, default to 1.</p></li>
<li><p><strong>gain_hf</strong> (<em>float</em>) Linear gain applying to high frequencies, default to 1.</p></li>
<li><p><strong>gain_lf</strong> (<em>float</em>) Linear gain applying to low frequencies, default to 1.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.gain">
<code class="sig-name descname">gain</code><a class="headerlink" href="#palace.Source.gain" title="Permalink to this definition"></a></dt>
<dd><p>Base linear volume gain, default to 1.0.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>ValueError</strong> If set to a negative value.</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.gain_auto">
<code class="sig-name descname">gain_auto</code><a class="headerlink" href="#palace.Source.gain_auto" title="Permalink to this definition"></a></dt>
<dd><p>Whether automatically adjust gains.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><ul class="simple">
<li><p><strong>direct_hf</strong> (<em>bool</em>) Direct paths high frequency gain, default to <cite>True</cite>.</p></li>
<li><p><strong>send</strong> (<em>bool</em>) Send paths gain, default to <cite>True</cite>.</p></li>
<li><p><strong>send_hf</strong> (<em>bool</em>) Send paths high-frequency, default to <cite>True</cite>.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.gain_range">
<code class="sig-name descname">gain_range</code><a class="headerlink" href="#palace.Source.gain_range" title="Permalink to this definition"></a></dt>
<dd><p>The range which the sources gain is clamped to.</p>
<p>This is used after distance and cone attenuation are applied
to the gain base and before the adjustments of the filter gain.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><ul class="simple">
<li><p><strong>mingain</strong> (<em>float</em>) Minimum gain, default to 0.</p></li>
<li><p><strong>maxgain</strong> (<em>float</em>) Maximum gain, default to 1.</p></li>
</ul>
</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> If set to a value where <cite>mingain</cite> is greater than <cite>maxgain</cite>
or either of them is outside of the [0, 1] interval.</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.group">
<code class="sig-name descname">group</code><a class="headerlink" href="#palace.Source.group" title="Permalink to this definition"></a></dt>
<dd><p>Parent group of this source.</p>
<p>The parent group influences all sources that belong to it.
A source may only be the child of one <cite>SourceGroup</cite> at a time,
although that source group may belong to another source group.</p>
<p>This is <cite>None</cite> when the source does not belong to any group.
On the other hand, setting it to <cite>None</cite> removes the source
from its current group.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#palace.SourceGroup" title="palace.SourceGroup"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SourceGroup</span></code></a></dt><dd><p>A group of <cite>Source</cite> references</p>
</dd>
</dl>
</div>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.latency">
<em class="property">property </em><code class="sig-name descname">latency</code><a class="headerlink" href="#palace.Source.latency" title="Permalink to this definition"></a></dt>
<dd><p>Source latency in nanoseconds.</p>
<p>If <cite>AL_SOFT_source_latency</cite> extension is unsupported,
this will be 0.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.latency_seconds">
<em class="property">property </em><code class="sig-name descname">latency_seconds</code><a class="headerlink" href="#palace.Source.latency_seconds" title="Permalink to this definition"></a></dt>
<dd><p>Source latency in seconds.</p>
<p>If <cite>AL_SOFT_source_latency</cite> extension is unsupported,
this will be 0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.looping">
<code class="sig-name descname">looping</code><a class="headerlink" href="#palace.Source.looping" title="Permalink to this definition"></a></dt>
<dd><p>Whether the source should loop.</p>
<p>The loop points are determined by the playing buffer or decoder.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.offset">
<code class="sig-name descname">offset</code><a class="headerlink" href="#palace.Source.offset" title="Permalink to this definition"></a></dt>
<dd><p>Source offset in sample frames.</p>
<p>For streaming sources, this will be
based on decoders read position.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.offset_seconds">
<em class="property">property </em><code class="sig-name descname">offset_seconds</code><a class="headerlink" href="#palace.Source.offset_seconds" title="Permalink to this definition"></a></dt>
<dd><p>Source offset in seconds.</p>
<p>For streaming sources, this will be based on
the decoders read position.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.orientation">
<code class="sig-name descname">orientation</code><a class="headerlink" href="#palace.Source.orientation" title="Permalink to this definition"></a></dt>
<dd><p>3D orientation of the source.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><ul class="simple">
<li><p><strong>at</strong> (<em>Tuple[float, float, float]</em>) Relative position.</p></li>
<li><p><strong>up</strong> (<em>Tuple[float, float, float]</em>) Relative direction.</p></li>
</ul>
</p>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>Unlike <cite>AL_EXT_BFORMAT</cite> extension this property
comes from, this also affects the facing direction.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.outer_cone_gains">
<code class="sig-name descname">outer_cone_gains</code><a class="headerlink" href="#palace.Source.outer_cone_gains" title="Permalink to this definition"></a></dt>
<dd><p>Gain when listener is out of the sources outer cone area.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><ul class="simple">
<li><p><strong>gain</strong> (<em>float</em>) Linear gain applying to all frequencies, default to 1.</p></li>
<li><p><strong>gain_hf</strong> (<em>float</em>) Linear gain applying extra attenuation to high frequencies
creating a low-pass effect, default to 1. It has no effect
without the <cite>ALC_EXT_EFX</cite> extension.</p></li>
</ul>
</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> If either of the gains is set to a value
outside of the [0, 1] interval.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.pause">
<code class="sig-name descname">pause</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Source.pause" title="Permalink to this definition"></a></dt>
<dd><p>Pause the source if it is playing.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.paused">
<em class="property">property </em><code class="sig-name descname">paused</code><a class="headerlink" href="#palace.Source.paused" title="Permalink to this definition"></a></dt>
<dd><p>Whether the source is currently paused.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.pitch">
<code class="sig-name descname">pitch</code><a class="headerlink" href="#palace.Source.pitch" title="Permalink to this definition"></a></dt>
<dd><p>Linear pitch shift base, default to 1.0.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>ValueError</strong> If set to a nonpositive value.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.playing">
<em class="property">property </em><code class="sig-name descname">playing</code><a class="headerlink" href="#palace.Source.playing" title="Permalink to this definition"></a></dt>
<dd><p>Whether the source is currently playing.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.position">
<code class="sig-name descname">position</code><a class="headerlink" href="#palace.Source.position" title="Permalink to this definition"></a></dt>
<dd><p>3D position of the source.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.priority">
<code class="sig-name descname">priority</code><a class="headerlink" href="#palace.Source.priority" title="Permalink to this definition"></a></dt>
<dd><p>Playback priority (natural number).</p>
<p>The lowest priority sources will be forcefully stopped
when no more mixing sources are available and higher priority
sources are played.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.radius">
<code class="sig-name descname">radius</code><a class="headerlink" href="#palace.Source.radius" title="Permalink to this definition"></a></dt>
<dd><p>Radius of the source, as if it is a sound-emitting sphere.</p>
<p>This has no effect without <cite>AL_EXT_SOURCE_RADIUS</cite> extension.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>ValueError</strong> If set to a negative value.</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.relative">
<code class="sig-name descname">relative</code><a class="headerlink" href="#palace.Source.relative" title="Permalink to this definition"></a></dt>
<dd><p>Whether the sources 3D parameters are relative to listener.</p>
<p>The affected parameters includes <cite>position</cite>, <cite>velocity</cite>,
and <cite>orientation</cite>.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.resampler_index">
<code class="sig-name descname">resampler_index</code><a class="headerlink" href="#palace.Source.resampler_index" title="Permalink to this definition"></a></dt>
<dd><p>Index of the resampler to use for this source.</p>
<p>The index must be nonnegative, from the resamplers returned
by <cite>Context.get_available_resamplers</cite>, and has no effect
without the <cite>AL_SOFT_source_resampler</cite> extension.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.resume">
<code class="sig-name descname">resume</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Source.resume" title="Permalink to this definition"></a></dt>
<dd><p>Resume the source if it is paused.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.rolloff_factors">
<code class="sig-name descname">rolloff_factors</code><a class="headerlink" href="#palace.Source.rolloff_factors" title="Permalink to this definition"></a></dt>
<dd><p>Rolloff factors for the direct and send paths.</p>
<p>This is effectively a distance scaling relative to
the reference distance.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><ul class="simple">
<li><p><strong>factor</strong> (<em>float</em>) Rolloff factor.</p></li>
<li><p><strong>room_factor</strong> (<em>float</em>) Room rolloff factor, default to 0 which disables
distance attenuation for send paths. This is because
the reverb engine will, by default, apply a more realistic
room decay based on the reverb decay time and distance.</p></li>
</ul>
</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> If either of rolloff factors is set to a negative value.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.sends">
<em class="property">property </em><code class="sig-name descname">sends</code><a class="headerlink" href="#palace.Source.sends" title="Permalink to this definition"></a></dt>
<dd><p>Collection of send path signals.</p>
<p>Send paths can be retrieved using a nonnegative index, which has
no effect if not less than the devices <cite>max_auxiliary_sends</cite>.</p>
<p>Each send path has two write-only descriptors,
<cite>effect</cite> and <cite>filter</cite>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">source</span><span class="o">.</span><span class="n">sends</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">effect</span> <span class="o">=</span> <span class="n">effect</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">source</span><span class="o">.</span><span class="n">sends</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">filter</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="mf">0.6</span><span class="p">,</span> <span class="mf">0.9</span>
</pre></div>
</div>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.spatialize">
<code class="sig-name descname">spatialize</code><a class="headerlink" href="#palace.Source.spatialize" title="Permalink to this definition"></a></dt>
<dd><p>Whether to enable 3D spatialization.</p>
<p>Either <cite>True</cite> (the source always has 3D spatialization
features), <cite>False</cite> (never has 3D spatialization features),
or <cite>None</cite> (spatialization is enabled based on playing
a mono sound or not, default).</p>
<p>This has no effect without
<cite>AL_SOFT_source_spatialize</cite> extension.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.stereo_angles">
<code class="sig-name descname">stereo_angles</code><a class="headerlink" href="#palace.Source.stereo_angles" title="Permalink to this definition"></a></dt>
<dd><p>Left and right channel angles, in radians.</p>
<p>The angles go counter-clockwise, with 0 being in front
and positive values going left.</p>
<p>This is only used for stereo playback and has no effect
without <cite>AL_EXT_STEREO_ANGLES</cite> extension.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.Source.stop">
<code class="sig-name descname">stop</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.Source.stop" title="Permalink to this definition"></a></dt>
<dd><p>Stop playback, releasing the buffer or decoder reference.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.Source.velocity">
<code class="sig-name descname">velocity</code><a class="headerlink" href="#palace.Source.velocity" title="Permalink to this definition"></a></dt>
<dd><p>3D velocity in units per second.</p>
<p>As with OpenAL, this does not actually alter the sources
position, and instead just alters the pitch as determined
by the doppler effect.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="source-groups">
<h2>Source Groups<a class="headerlink" href="#source-groups" title="Permalink to this headline"></a></h2>
<dl class="py class">
<dt id="palace.SourceGroup">
<em class="property">class </em><code class="sig-prename descclassname">palace.</code><code class="sig-name descname">SourceGroup</code><a class="headerlink" href="#palace.SourceGroup" title="Permalink to this definition"></a></dt>
<dd><p>A group of <cite>Source</cite> references.</p>
<p>For instance, setting <cite>SourceGroup.gain</cite> to 0.5 will halve the gain
of all sources in the group.</p>
<p>This can be used as a context manager that calls <cite>destroy</cite> upon
completion of the block, even if an error occurs.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>context</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="context.html#palace.Context" title="palace.Context"><em>Context</em></a><em>]</em><em>, </em><em>optional</em>) The context from which the source group is to be created.
By default <cite>current_context()</cite> is used.</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>RuntimeError</strong> If there is neither any context specified nor current.</p>
</dd>
</dl>
<dl class="py method">
<dt id="palace.SourceGroup.destroy">
<code class="sig-name descname">destroy</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.SourceGroup.destroy" title="Permalink to this definition"></a></dt>
<dd><p>Destroy the source group, remove and free all sources.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.SourceGroup.gain">
<code class="sig-name descname">gain</code><a class="headerlink" href="#palace.SourceGroup.gain" title="Permalink to this definition"></a></dt>
<dd><p>Source group gain.</p>
<p>This accumulates with its sources and sub-groups gain.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.SourceGroup.parent_group">
<code class="sig-name descname">parent_group</code><a class="headerlink" href="#palace.SourceGroup.parent_group" title="Permalink to this definition"></a></dt>
<dd><p>The parent source group of this source group.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>RuntimeException</strong> If this group is being added to its sub-group
(i.e. it would create a circular sub-group chain).</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="palace.SourceGroup.pause_all">
<code class="sig-name descname">pause_all</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.SourceGroup.pause_all" title="Permalink to this definition"></a></dt>
<dd><p>Pause all currently-playing sources under this group.</p>
<p>This is done recursively, including sub-groups.</p>
</dd></dl>
<dl class="py attribute">
<dt id="palace.SourceGroup.pitch">
<code class="sig-name descname">pitch</code><a class="headerlink" href="#palace.SourceGroup.pitch" title="Permalink to this definition"></a></dt>
<dd><p>Source group pitch.</p>
<p>This accumulates with its sources and sub-groups pitch.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.SourceGroup.resume_all">
<code class="sig-name descname">resume_all</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.SourceGroup.resume_all" title="Permalink to this definition"></a></dt>
<dd><p>Resume all currently-playing sources under this group.</p>
<p>This is done recursively, including sub-groups.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.SourceGroup.sources">
<em class="property">property </em><code class="sig-name descname">sources</code><a class="headerlink" href="#palace.SourceGroup.sources" title="Permalink to this definition"></a></dt>
<dd><p>Sources under this group.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.SourceGroup.stop_all">
<code class="sig-name descname">stop_all</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#palace.SourceGroup.stop_all" title="Permalink to this definition"></a></dt>
<dd><p>Stop all currently-playing sources under this group.</p>
<p>This is done recursively, including sub-groups.</p>
</dd></dl>
<dl class="py method">
<dt id="palace.SourceGroup.sub_groups">
<em class="property">property </em><code class="sig-name descname">sub_groups</code><a class="headerlink" href="#palace.SourceGroup.sub_groups" title="Permalink to this definition"></a></dt>
<dd><p>Source groups under this group.</p>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="buffer.html" title="Previous document">Resource Caching</a>
</li>
<li>
<a href="effect.html" title="Next document">Environmental Effects</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/reference/source.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,137 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Search &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<script src="_static/searchtools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="#" />
<script src="searchindex.js" defer></script>
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
</ul>
</nav>
</div>
<div class="body" role="main">
<h1 id="search-documentation">Search</h1>
<div id="fallback" class="admonition warning">
<script>$('#fallback').hide();</script>
<p>
Please activate JavaScript to enable the search
functionality.
</p>
</div>
<p>
Searching for multiple words only shows matches that contain
all words.
</p>
<form action="" method="get">
<input type="text" name="q" aria-labelledby="search-documentation" value="" />
<input type="submit" value="search" />
<span id="search-progress" style="padding-left: 10px"></span>
</form>
<div id="search-results">
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -1,181 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Context Creation &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Play an Audio" href="play-audio.html" />
<link rel="prev" title="Tutorial" href="index.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Tutorial</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">Context Creation</a></li>
<li class="toctree-l2"><a class="reference internal" href="play-audio.html">Play an Audio</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html">Source Manipulation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../reference/index.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="index.html" title="Previous document">Tutorial</a>
</li>
<li>
<a href="play-audio.html" title="Next document">Play an Audio</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="context-creation">
<h1>Context Creation<a class="headerlink" href="#context-creation" title="Permalink to this headline"></a></h1>
<p>A context is an object that allows palace to access OpenAL,
which is essential when you work with palace. Context maintains
the audio environment and contains environment settings and components
such as sources, buffers, and effects.</p>
<div class="section" id="creating-a-device-object">
<h2>Creating a Device Object<a class="headerlink" href="#creating-a-device-object" title="Permalink to this headline"></a></h2>
<p>To create a context, we must first create a device,
since its a parameter of the context object.</p>
<p>To create an object, well, you just have to instantiate
the <a class="reference internal" href="../reference/device.html#palace.Device" title="palace.Device"><code class="xref py py-class docutils literal notranslate"><span class="pre">Device</span></code></a> class.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">palace</span> <span class="kn">import</span> <span class="n">Device</span>
<span class="k">with</span> <span class="n">Device</span><span class="p">()</span> <span class="k">as</span> <span class="n">dev</span><span class="p">:</span>
<span class="c1"># Your code goes here</span>
</pre></div>
</div>
<p>This is how you declare a <a class="reference internal" href="../reference/device.html#palace.Device" title="palace.Device"><code class="xref py py-class docutils literal notranslate"><span class="pre">Device</span></code></a> object with the default device.
There can be several devices available, which can be found
in <a class="reference internal" href="../reference/device.html#palace.device_names" title="palace.device_names"><code class="xref py py-data docutils literal notranslate"><span class="pre">device_names</span></code></a>.</p>
</div>
<div class="section" id="creating-a-context">
<h2>Creating a Context<a class="headerlink" href="#creating-a-context" title="Permalink to this headline"></a></h2>
<p>Now that weve created a device, we can create the context:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">palace</span> <span class="kn">import</span> <span class="n">Device</span><span class="p">,</span> <span class="n">Context</span>
<span class="k">with</span> <span class="n">Device</span><span class="p">()</span> <span class="k">as</span> <span class="n">dev</span><span class="p">,</span> <span class="n">Context</span><span class="p">(</span><span class="n">dev</span><span class="p">)</span> <span class="k">as</span> <span class="n">ctx</span><span class="p">:</span>
<span class="c1"># Your code goes here</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="index.html" title="Previous document">Tutorial</a>
</li>
<li>
<a href="play-audio.html" title="Next document">Play an Audio</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/tutorial/context.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,172 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tutorial &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Context Creation" href="context.html" />
<link rel="prev" title="Installation" href="../installation.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Tutorial</a><ul>
<li class="toctree-l2"><a class="reference internal" href="context.html">Context Creation</a></li>
<li class="toctree-l2"><a class="reference internal" href="play-audio.html">Play an Audio</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html">Source Manipulation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../reference/index.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="../installation.html" title="Previous document">Installation</a>
</li>
<li>
<a href="context.html" title="Next document">Context Creation</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="tutorial">
<h1>Tutorial<a class="headerlink" href="#tutorial" title="Permalink to this headline"></a></h1>
<p>This tutorial will guide you on:</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="context.html">Context Creation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="context.html#creating-a-device-object">Creating a Device Object</a></li>
<li class="toctree-l2"><a class="reference internal" href="context.html#creating-a-context">Creating a Context</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="play-audio.html">Play an Audio</a><ul>
<li class="toctree-l2"><a class="reference internal" href="play-audio.html#creating-a-source">Creating a Source</a></li>
<li class="toctree-l2"><a class="reference internal" href="play-audio.html#decode-the-audio-file">Decode the Audio File</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="source.html">Source Manipulation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="source.html#moving-the-source">Moving the Source</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html#speed-and-pitch">Speed and Pitch</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html#air-absorption-factor">Air Absorption Factor</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="../installation.html" title="Previous document">Installation</a>
</li>
<li>
<a href="context.html" title="Next document">Context Creation</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/tutorial/index.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,230 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Play an Audio &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Source Manipulation" href="source.html" />
<link rel="prev" title="Context Creation" href="context.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Tutorial</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="context.html">Context Creation</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Play an Audio</a></li>
<li class="toctree-l2"><a class="reference internal" href="source.html">Source Manipulation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../reference/index.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="context.html" title="Previous document">Context Creation</a>
</li>
<li>
<a href="source.html" title="Next document">Source Manipulation</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="play-an-audio">
<h1>Play an Audio<a class="headerlink" href="#play-an-audio" title="Permalink to this headline"></a></h1>
<p>Now that you know how to create a context,
lets get into the most essential use case: playing audio.</p>
<div class="section" id="creating-a-source">
<h2>Creating a Source<a class="headerlink" href="#creating-a-source" title="Permalink to this headline"></a></h2>
<p>To play an audio, you have to create a source. This source
is an imaginary sound broadcaster, whose positions and properties
can be changed to create desired effects.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">palace</span> <span class="kn">import</span> <span class="n">Device</span><span class="p">,</span> <span class="n">Context</span><span class="p">,</span> <span class="n">Source</span>
<span class="k">with</span> <span class="n">Device</span><span class="p">()</span> <span class="k">as</span> <span class="n">dev</span><span class="p">,</span> <span class="n">Context</span><span class="p">(</span><span class="n">dev</span><span class="p">)</span> <span class="k">as</span> <span class="n">ctx</span><span class="p">:</span>
<span class="k">with</span> <span class="n">Source</span><span class="p">()</span> <span class="k">as</span> <span class="n">src</span><span class="p">:</span>
<span class="c1"># to be written</span>
</pre></div>
</div>
<p>Just like for the case of <a class="reference internal" href="../reference/context.html#palace.Context" title="palace.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context</span></code></a>, <a class="reference internal" href="../reference/source.html#palace.Source" title="palace.Source"><code class="xref py py-class docutils literal notranslate"><span class="pre">Source</span></code></a> creation
requires a context, but here the context is passed implicitly.</p>
</div>
<div class="section" id="decode-the-audio-file">
<h2>Decode the Audio File<a class="headerlink" href="#decode-the-audio-file" title="Permalink to this headline"></a></h2>
<p>Palace has a module level function <a class="reference internal" href="../reference/decoder.html#palace.decode" title="palace.decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">decode()</span></code></a>, which decodes audio file
automatically, and this decoded file is a <a class="reference internal" href="../reference/decoder.html#palace.Decoder" title="palace.Decoder"><code class="xref py py-class docutils literal notranslate"><span class="pre">Decoder</span></code></a> object. This object
can be played by a simple <a class="reference internal" href="../reference/decoder.html#palace.Decoder.play" title="palace.Decoder.play"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Decoder.play()</span></code></a> method.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">palace</span> <span class="kn">import</span> <span class="n">Device</span><span class="p">,</span> <span class="n">Context</span><span class="p">,</span> <span class="n">Source</span><span class="p">,</span> <span class="n">decode</span>
<span class="n">filename</span> <span class="o">=</span> <span class="s1">&#39;some_audio.ogg&#39;</span>
<span class="k">with</span> <span class="n">Device</span><span class="p">()</span> <span class="k">as</span> <span class="n">dev</span><span class="p">,</span> <span class="n">Context</span><span class="p">(</span><span class="n">dev</span><span class="p">)</span> <span class="k">as</span> <span class="n">ctx</span><span class="p">:</span>
<span class="k">with</span> <span class="n">Source</span><span class="p">()</span> <span class="k">as</span> <span class="n">src</span><span class="p">:</span>
<span class="n">dec</span> <span class="o">=</span> <span class="n">decode</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
</pre></div>
</div>
<p>We are almost there. Now, lets look at the document for <a class="reference internal" href="../reference/decoder.html#palace.Decoder.play" title="palace.Decoder.play"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Decoder.play()</span></code></a>.
The method takes 3 parameters: <code class="docutils literal notranslate"><span class="pre">chunk_len</span></code>, <code class="docutils literal notranslate"><span class="pre">queue_size</span></code>, and <code class="docutils literal notranslate"><span class="pre">source</span></code>.</p>
<p>The source object is optional, because if you dont have it, a new source
will be generated by default.</p>
<p>The audio is divided into chunks, each of which is of length <code class="docutils literal notranslate"><span class="pre">chunk_len</span></code>.
Then <code class="docutils literal notranslate"><span class="pre">queue_size</span></code> is the number of these chunks that it will play.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">palace</span> <span class="kn">import</span> <span class="n">Device</span><span class="p">,</span> <span class="n">Context</span><span class="p">,</span> <span class="n">Source</span><span class="p">,</span> <span class="n">decode</span>
<span class="n">filename</span> <span class="o">=</span> <span class="s1">&#39;some_audio.ogg&#39;</span>
<span class="k">with</span> <span class="n">Device</span><span class="p">()</span> <span class="k">as</span> <span class="n">dev</span><span class="p">,</span> <span class="n">Context</span><span class="p">(</span><span class="n">dev</span><span class="p">)</span> <span class="k">as</span> <span class="n">ctx</span><span class="p">:</span>
<span class="k">with</span> <span class="n">Source</span><span class="p">()</span> <span class="k">as</span> <span class="n">src</span><span class="p">:</span>
<span class="n">dec</span> <span class="o">=</span> <span class="n">decode</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
<span class="n">dec</span><span class="o">.</span><span class="n">play</span><span class="p">(</span><span class="mi">12000</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="n">src</span><span class="p">)</span>
</pre></div>
</div>
<p>But we dont want it to play only a small part of the audio. We want it to
play all of it. How do we do that? The answer is a loop.</p>
<p>There is a method, <a class="reference internal" href="../reference/context.html#palace.Context.update" title="palace.Context.update"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Context.update()</span></code></a>, which update the context and the source.
When the source is updated, it will be filled with new chunks of data from
the decoder.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">palace</span> <span class="kn">import</span> <span class="n">Device</span><span class="p">,</span> <span class="n">Context</span><span class="p">,</span> <span class="n">Source</span><span class="p">,</span> <span class="n">decode</span>
<span class="n">filename</span> <span class="o">=</span> <span class="s1">&#39;some_audio.ogg&#39;</span>
<span class="k">with</span> <span class="n">Device</span><span class="p">()</span> <span class="k">as</span> <span class="n">dev</span><span class="p">,</span> <span class="n">Context</span><span class="p">(</span><span class="n">dev</span><span class="p">)</span> <span class="k">as</span> <span class="n">ctx</span><span class="p">:</span>
<span class="k">with</span> <span class="n">Source</span><span class="p">()</span> <span class="k">as</span> <span class="n">src</span><span class="p">:</span>
<span class="n">dec</span> <span class="o">=</span> <span class="n">decode</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
<span class="n">dec</span><span class="o">.</span><span class="n">play</span><span class="p">(</span><span class="mi">12000</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="n">src</span><span class="p">)</span>
<span class="k">while</span> <span class="n">src</span><span class="o">.</span><span class="n">playing</span><span class="p">:</span>
<span class="n">ctx</span><span class="o">.</span><span class="n">update</span><span class="p">()</span>
</pre></div>
</div>
<p>If you tried this code for a song, you will find that its a bit rush.
That is because the source is renewed too fast. So, a simple solution
is to <code class="docutils literal notranslate"><span class="pre">sleep</span></code> for a while.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">time</span> <span class="kn">import</span> <span class="n">sleep</span>
<span class="kn">from</span> <span class="nn">palace</span> <span class="kn">import</span> <span class="n">Device</span><span class="p">,</span> <span class="n">Context</span><span class="p">,</span> <span class="n">Source</span><span class="p">,</span> <span class="n">decode</span>
<span class="n">filename</span> <span class="o">=</span> <span class="s1">&#39;some_audio.ogg&#39;</span>
<span class="k">with</span> <span class="n">Device</span><span class="p">()</span> <span class="k">as</span> <span class="n">dev</span><span class="p">,</span> <span class="n">Context</span><span class="p">(</span><span class="n">dev</span><span class="p">)</span> <span class="k">as</span> <span class="n">ctx</span><span class="p">:</span>
<span class="k">with</span> <span class="n">Source</span><span class="p">()</span> <span class="k">as</span> <span class="n">src</span><span class="p">:</span>
<span class="n">dec</span> <span class="o">=</span> <span class="n">decode</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
<span class="n">dec</span><span class="o">.</span><span class="n">play</span><span class="p">(</span><span class="mi">12000</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="n">src</span><span class="p">)</span>
<span class="k">while</span> <span class="n">src</span><span class="o">.</span><span class="n">playing</span><span class="p">:</span>
<span class="n">sleep</span><span class="p">(</span><span class="mf">0.025</span><span class="p">)</span>
<span class="n">ctx</span><span class="o">.</span><span class="n">update</span><span class="p">()</span>
</pre></div>
</div>
<p>Congratulation! Enjoy your music before we get to the next part of this tutorial.</p>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="context.html" title="Previous document">Context Creation</a>
</li>
<li>
<a href="source.html" title="Next document">Source Manipulation</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/tutorial/play-audio.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,216 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Source Manipulation &#8212; palace 0.2.1 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Reference" href="../reference/index.html" />
<link rel="prev" title="Play an Audio" href="play-audio.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Tutorial</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="context.html">Context Creation</a></li>
<li class="toctree-l2"><a class="reference internal" href="play-audio.html">Play an Audio</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Source Manipulation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../reference/index.html">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design Principles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Getting Involved</a></li>
<li class="toctree-l1"><a class="reference internal" href="../copying.html">Copying</a></li>
</ul>
<h3>Quick Navigation</h3>
<ul>
<li class="toctree-l1">
<a class="reference external" href="https://pypi.org/project/palace/">
Python Package Index
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://travis-ci.com/github/McSinyx/palace">
Travis CI Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://ci.appveyor.com/project/McSinyx/palace">
AppVeyor Build
</a>
</li>
<li class="toctree-l1">
<a class="reference external" href="https://github.com/McSinyx/palace">
GitHub Repository
</a>
</li>
<li class="toctree-l1">
<a class="reference external"
href="https://matrix.to/#/#palace-dev:matrix.org">
Matrix Chat Room
</a>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="related top">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="play-audio.html" title="Previous document">Play an Audio</a>
</li>
<li>
<a href="../reference/index.html" title="Next document">Reference</a>
&rarr;
</li>
</ul>
</nav>
</div>
<div class="body" role="main">
<div class="section" id="source-manipulation">
<h1>Source Manipulation<a class="headerlink" href="#source-manipulation" title="Permalink to this headline"></a></h1>
<p>We have created a source in the last section.
As said previously, its properties can be manipulated to create wanted effects.</p>
<div class="section" id="moving-the-source">
<h2>Moving the Source<a class="headerlink" href="#moving-the-source" title="Permalink to this headline"></a></h2>
<p>Changing <a class="reference internal" href="../reference/source.html#palace.Source.position" title="palace.Source.position"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Source.position</span></code></a> is one of the most noticeable,
but first, we have to enable spatialization via <a class="reference internal" href="../reference/source.html#palace.Source.spatialize" title="palace.Source.spatialize"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Source.spatialize</span></code></a>.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">time</span> <span class="kn">import</span> <span class="n">sleep</span>
<span class="kn">from</span> <span class="nn">palace</span> <span class="kn">import</span> <span class="n">Device</span><span class="p">,</span> <span class="n">Context</span><span class="p">,</span> <span class="n">Source</span><span class="p">,</span> <span class="n">decode</span>
<span class="k">with</span> <span class="n">Device</span><span class="p">()</span> <span class="k">as</span> <span class="n">device</span><span class="p">,</span> <span class="n">Context</span><span class="p">(</span><span class="n">device</span><span class="p">)</span> <span class="k">as</span> <span class="n">context</span><span class="p">,</span> <span class="n">Source</span><span class="p">()</span> <span class="k">as</span> <span class="n">source</span><span class="p">:</span>
<span class="n">source</span><span class="o">.</span><span class="n">spatialize</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">decoder</span> <span class="o">=</span> <span class="n">decode</span><span class="p">(</span><span class="s1">&#39;some_audio.ogg&#39;</span><span class="p">)</span>
<span class="n">decoder</span><span class="o">.</span><span class="n">play</span><span class="p">(</span><span class="mi">12000</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="n">source</span><span class="p">)</span>
<span class="k">while</span> <span class="n">source</span><span class="o">.</span><span class="n">playing</span><span class="p">:</span>
<span class="n">sleep</span><span class="p">(</span><span class="mf">0.025</span><span class="p">)</span>
<span class="n">context</span><span class="o">.</span><span class="n">update</span><span class="p">()</span>
</pre></div>
</div>
<p>Now, we can set the position of the source in this virtual 3D space.
The position is a 3-tuple indicating the coordinate of the source.
The axes are aligned according to the normal coordinate system:</p>
<ul class="simple">
<li><p>The x-axis goes from left to right</p></li>
<li><p>The y-axis goes from below to above</p></li>
<li><p>The z-axis goes from front to back</p></li>
</ul>
<p>For example, this will set the source above the listener:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">src</span><span class="o">.</span><span class="n">position</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>For this too work for stereo, you have to have HRTF enabled.
You can check that via <a class="reference internal" href="../reference/device.html#palace.Device.current_hrtf" title="palace.Device.current_hrtf"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Device.current_hrtf</span></code></a>.</p>
</div>
<p>You can as well use a function to move the source automatically by writing
a function that generate positions. A simple example is circular motion.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">takewhile</span><span class="p">,</span> <span class="n">count</span>
<span class="o">...</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">takewhile</span><span class="p">(</span><span class="n">src</span><span class="o">.</span><span class="n">playing</span><span class="p">,</span> <span class="n">count</span><span class="p">(</span><span class="n">step</span><span class="o">=</span><span class="mf">0.025</span><span class="p">)):</span>
<span class="n">source</span><span class="o">.</span><span class="n">position</span> <span class="o">=</span> <span class="n">sin</span><span class="p">(</span><span class="n">i</span><span class="p">),</span> <span class="mi">0</span><span class="p">,</span> <span class="n">cos</span><span class="p">(</span><span class="o">-</span><span class="n">i</span><span class="p">)</span>
<span class="o">...</span>
</pre></div>
</div>
<p>A more well-written example of this can be found <a class="reference external" href="https://github.com/McSinyx/palace/blob/master/examples/palace-hrtf.py">in our repository</a>.</p>
</div>
<div class="section" id="speed-and-pitch">
<h2>Speed and Pitch<a class="headerlink" href="#speed-and-pitch" title="Permalink to this headline"></a></h2>
<p>Modifying <code class="xref py py-attr docutils literal notranslate"><span class="pre">pitch</span></code> changes the playing speed, effectively changing
pitch. Pitch can be any positive number.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">src</span><span class="o">.</span><span class="n">pitch</span> <span class="o">=</span> <span class="mi">2</span> <span class="c1"># high pitch</span>
<span class="n">src</span><span class="o">.</span><span class="n">pitch</span> <span class="o">=</span> <span class="mf">0.4</span> <span class="c1"># low pitch</span>
</pre></div>
</div>
</div>
<div class="section" id="air-absorption-factor">
<h2>Air Absorption Factor<a class="headerlink" href="#air-absorption-factor" title="Permalink to this headline"></a></h2>
<p><a class="reference internal" href="../reference/source.html#palace.Source.air_absorption_factor" title="palace.Source.air_absorption_factor"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Source.air_absorption_factor</span></code></a> simulates atmospheric high-frequency
air absorption. Higher values simulate foggy air and lower values simulate
drier air.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">src</span><span class="o">.</span><span class="n">air_absorption_factor</span> <span class="o">=</span> <span class="mi">9</span> <span class="c1"># very high humidity</span>
<span class="n">src</span><span class="o">.</span><span class="n">air_absorption_factor</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># dry air (default)</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="related bottom">
&nbsp;
<nav id="rellinks">
<ul>
<li>
&larr;
<a href="play-audio.html" title="Previous document">Play an Audio</a>
</li>
<li>
<a href="../reference/index.html" title="Next document">Reference</a>
&rarr;
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, 2020 Nguyễn Gia Phong et al.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/tutorial/source.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,2 +0,0 @@
<!-- Redirect to build/html -->
<meta HTTP-EQUIV="REFRESH" content="0; url=html/">

View File

@ -1,2 +0,0 @@
palace
sphinx >= 3.2

View File

@ -1,67 +0,0 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'palace'
copyright = '2019, 2020 Nguyễn Gia Phong et al'
author = 'Nguyễn Gia Phong et al.'
# The full version, including alpha/beta/rc tags
release = '0.2.1'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon']
napoleon_google_docstring = False
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_sidebars = {
'**': ['globaltoc.html', 'quicknav.html', 'searchbox.html']}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_theme_options = {'fixed_sidebar': True, 'show_relbars': True}
# -- Options for LaTeX output ------------------------------------------------
latex_elements = dict(papersize='a4paper',
fontpkg='\\usepackage{lmodern}',
babel='\\usepackage[english,vietnamese]{babel}')