diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-02-01 14:11:04 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-02-01 14:22:57 +0300 |
commit | 781dd5edb5b74ecb417a16c28eab31483fc3d11a (patch) | |
tree | e5c142f2eef1cbcb1ed6dc243ec9707fe64f8d5f /extern/audaspace/bindings/doc | |
parent | cd317fab65e1b6c1652ba7a58786a8cc5bd11843 (diff) |
Fix audaspace mess in 2.8
All these files were removed since accidental commit, revert and merge in 2.8.
ea31f0ac3b877e + 0a4e170c28cec + 11f9a23a286c17f + 7b27b10fa6a6
Diffstat (limited to 'extern/audaspace/bindings/doc')
-rw-r--r-- | extern/audaspace/bindings/doc/conf.py.in | 261 | ||||
-rw-r--r-- | extern/audaspace/bindings/doc/device.rst | 7 | ||||
-rw-r--r-- | extern/audaspace/bindings/doc/handle.rst | 7 | ||||
-rw-r--r-- | extern/audaspace/bindings/doc/index.rst | 35 | ||||
-rw-r--r-- | extern/audaspace/bindings/doc/sequence.rst | 7 | ||||
-rw-r--r-- | extern/audaspace/bindings/doc/sequence_entry.rst | 7 | ||||
-rw-r--r-- | extern/audaspace/bindings/doc/sound.rst | 7 | ||||
-rw-r--r-- | extern/audaspace/bindings/doc/tutorials.rst | 166 |
8 files changed, 497 insertions, 0 deletions
diff --git a/extern/audaspace/bindings/doc/conf.py.in b/extern/audaspace/bindings/doc/conf.py.in new file mode 100644 index 00000000000..e08efbcf7f6 --- /dev/null +++ b/extern/audaspace/bindings/doc/conf.py.in @@ -0,0 +1,261 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# audaspace documentation build configuration file, created by +# sphinx-quickstart on Tue Sep 9 01:48:48 2014. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# 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. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# 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', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = [] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = 'audaspace' +copyright = '2009-2015, Jörg Müller' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '@AUDASPACE_VERSION@' +# The full version, including alpha/beta/rc tags. +release = '@AUDASPACE_LONG_VERSION@' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + + +# -- 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' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# "<project> v<release> documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# 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 = [] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'audaspacedoc' + + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ('index', 'audaspace.tex', 'audaspace Documentation', + 'Jörg Müller', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'audaspace', 'audaspace Documentation', + ['Jörg Müller'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'audaspace', 'audaspace Documentation', + 'Jörg Müller', 'audaspace', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False diff --git a/extern/audaspace/bindings/doc/device.rst b/extern/audaspace/bindings/doc/device.rst new file mode 100644 index 00000000000..fd6b334022c --- /dev/null +++ b/extern/audaspace/bindings/doc/device.rst @@ -0,0 +1,7 @@ +Device +====== + +.. currentmodule:: aud +.. autoclass:: Device + :members: + diff --git a/extern/audaspace/bindings/doc/handle.rst b/extern/audaspace/bindings/doc/handle.rst new file mode 100644 index 00000000000..aceedbca3a6 --- /dev/null +++ b/extern/audaspace/bindings/doc/handle.rst @@ -0,0 +1,7 @@ +Handle +====== + +.. currentmodule:: aud +.. autoclass:: Handle + :members: + diff --git a/extern/audaspace/bindings/doc/index.rst b/extern/audaspace/bindings/doc/index.rst new file mode 100644 index 00000000000..b8a26822949 --- /dev/null +++ b/extern/audaspace/bindings/doc/index.rst @@ -0,0 +1,35 @@ +.. audaspace documentation master file, created by + sphinx-quickstart on Tue Sep 9 01:48:48 2014. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to audaspace's documentation! +===================================== + +.. automodule:: aud + +This documentation is valid for both the Python and C bindings of audaspace. If you are looking for installation instructions check the `C++ API documentation <../index.html>`_. As C is not an object oriented language everything is accessible via functions where the first paramter is always the object. For methods these are named as ``AUD_ClassName_method()`` and properties are accessed via ``AUD_ClassName_property_get/set()``. Python users simply ``import aud`` to access the library. + +.. toctree:: + :maxdepth: 2 + + tutorials + +Classes: + +.. toctree:: + :maxdepth: 2 + + device + sound + handle + sequence + sequence_entry + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/extern/audaspace/bindings/doc/sequence.rst b/extern/audaspace/bindings/doc/sequence.rst new file mode 100644 index 00000000000..16fcb00f4dc --- /dev/null +++ b/extern/audaspace/bindings/doc/sequence.rst @@ -0,0 +1,7 @@ +Sequence +======== + +.. currentmodule:: aud +.. autoclass:: Sequence + :members: + diff --git a/extern/audaspace/bindings/doc/sequence_entry.rst b/extern/audaspace/bindings/doc/sequence_entry.rst new file mode 100644 index 00000000000..0a3d83388e9 --- /dev/null +++ b/extern/audaspace/bindings/doc/sequence_entry.rst @@ -0,0 +1,7 @@ +Sequence Entry +============== + +.. currentmodule:: aud +.. autoclass:: SequenceEntry + :members: + diff --git a/extern/audaspace/bindings/doc/sound.rst b/extern/audaspace/bindings/doc/sound.rst new file mode 100644 index 00000000000..2f14721cf3a --- /dev/null +++ b/extern/audaspace/bindings/doc/sound.rst @@ -0,0 +1,7 @@ +Sound +===== + +.. currentmodule:: aud +.. autoclass:: Sound + :members: + diff --git a/extern/audaspace/bindings/doc/tutorials.rst b/extern/audaspace/bindings/doc/tutorials.rst new file mode 100644 index 00000000000..55f51d9ee2f --- /dev/null +++ b/extern/audaspace/bindings/doc/tutorials.rst @@ -0,0 +1,166 @@ +Tutorials +========= + +Introduction +------------ + +The C and Python binding for audaspace were designed with simplicity in mind. This means however that to use the full capabilities of audaspace, there is no way around the C++ library. + +Simple Demo +----------- + +The **simple.py** example program contains all the basic building blocks for an application using audaspace. These building blocks are basically the classes :class:`aud.Device`, :class:`aud.Sound` and :class:`aud.Handle`. + +We start with importing :mod:`aud` and :mod:`time` as the modules we need for our simple example. + +.. code-block:: python + + #!/usr/bin/python + import aud, time + +The first step now is to open an output device and this can simply be done by allocating a :class:`aud.Device` object. + +.. code-block:: python + + device = aud.Device() + +To create a sound we can choose to load one from a :func:`aud.Sound.file`, or we use one of our signal generators. We decide to do the latter and create a :func:`aud.Sound.sine` signal with a frequency of 440 Hz. + +.. code-block:: python + + sine = aud.Sound.sine(440) + +.. note:: At this point nothing is playing back yet, :class:`aud.Sound` objects are just descriptions of sounds. + +However instead of a sine wave, we would like to have a square wave to produce a more retro gaming sound. We could of course use the :func:`aud.Sound.square` generator instead of sine, but we want to show how to apply effects, so we apply a :func:`aud.Sound.threshold` which makes a square wave out of our sine too, even if less efficient than directly generating the square wave. + +.. code-block:: python + + square = sine.threshold() + +.. note:: The :class:`aud.Sound` class offers generator and effect functions. + +The we can play our sound by calling the :func:`aud.Device.play` method of our device. This method returns a :class:`aud.Handle` which is used to control the playback of the sound. + +.. code-block:: python + + handle = device.play(square) + +Now if we do nothing else anymore the application will quit immediately, so we won't hear much of our square wave, so we decide to wait for three seconds before quitting the application by calling :func:`time.sleep`. + +.. code-block:: python + + time.sleep(3) + +Audioplayer +----------- + +Now that we know the basics of audaspace, we can build our own music player easily by just slightly changing the previous program. The **player.py** example does exactly that, let's have a short look at the differences: + +Instead of creating a sine signal and thresholding it, we in fact use the :func:`aud.Sound.file` function to load a sound from a file. The filename we pass is the first command line argument our application got. + +.. code-block:: python + + sound = aud.Sound.file(sys.argv[1]) + +When the sound gets played back we now want to wait until the whole file has been played, so we use the :data:`aud.Handle.status` property to determine whether the sound finished playing. + +.. code-block:: python + + while handle.status: + time.sleep(0.1) + +We don't make any error checks if the user actually added a command line argument. As an exercise you could extend this program to play any number of command line supplied files in sequence. + +Siren +----- + +Let's get a little bit more complex. The **siren.py** example plays a generated siren sound that circles around your head. Depending on how many speakers you have and if the output device used supports the speaker setup, you will hear this effect. With stereo speakers you should at least hear some left-right-panning. + +We start off again with importing the modules we need and we also define some properties of our siren sound. We want it to consist of two sine sounds with different frequencies. We define a length for the sine sounds and how long a fade in/out should take. We also know already how to open a device. + +.. code-block:: python + + #!/usr/bin/python + import aud, math, time + length = 0.5 + fadelength = 0.05 + + device = aud.Device() + +The next thing to do is to define our sine waves and apply all the required effects. As each of the effect functions returns the corresponding sound, we can easily chain those calls together. + +.. code-block:: python + + high = aud.Sound.sine(880).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length) + low = aud.Sound.sine(700).limit(0, length).fadein(0, fadelength).fadeout(length - fadelength, length).volume(0.6) + +The next step is to connect the two sines, which we do using the :func:`aud.Sound.join` function. + +.. code-block:: python + + sound = high.join(low) + +The generated siren sound can now be played back and what we also do is to loop it. Therefore we set the :data:`aud.Handle.loop_count` to a negative value to loop forever. + +.. code-block:: python + + handle = device.play(sound) + handle.loop_count = -1 + +Now we use some timing code to make sure our demo runs for 10 seconds, but we also use the time to update the location of our playing sound, with the :data:`aud.Handle.location` property, which is a three dimensional vector. The trigonometic calculation based on the running time of the program keeps the sound on the XZ plane letting it follow a circle around us. + +.. code-block:: python + + start = time.time() + + while time.time() - start < 10: + angle = time.time() - start + + handle.location = [math.sin(angle), 0, -math.cos(angle)] + +As an exercise you could try to let the sound come from the far left and go to the far right and a little bit in front of you within the 10 second runtime of the program. With this change you should be able to hear the volume of the sound change, depending on how far it is away from you. Updating the :data:`aud.Handle.velocity` property properly also enables the doppler effect. Compare your solution to the **siren2.py** demo. + +Tetris +------ + +The **tetris.py** demo application shows an even more complex application which generates retro tetris music. Looking at the source code there should be nothing new here, again the functions used from audaspace are the same as in the previous examples. In the :func:`parseNote` function all single notes get joined which leads to a very long chain of sounds. If you think of :func:`aud.Sound.join` as a function that creates a binary tree with the two joined sounds as leaves then the :func:`parseNote` function creates a very unbalanced tree. + +Insted we could rewrite the code to use two other classes: :class:`aud.Sequence` and :class:`aud.SequenceEntry` to sequence the notes. The **tetris2.py** application does exactly that. Before the while loop we add a variable that stores the current position in the score and create a new :class:`aud.Sequence` object. + +.. code-block:: python + + position = 0 + sequence = aud.Sequence() + +Then in the loop we can create the note simply by chaining the :func:`aud.Sound.square` generator and :func:`aud.Sound.fadein` and :func:`aud.Sound.fadeout` effects. + +.. code-block:: python + + note = aud.Sound.square(freq, rate).fadein(0, fadelength).fadeout(length - fadelength, fadelength) + +Now instead of using :func:`aud.Sound.limit` and :func:`aud.Sound.join` we simply add the sound to the sequence. + +.. code-block:: python + + entry = sequence.add(note, position, position + length, 0) + +The entry returned from the :func:`aud.Sequence.add` function is an object of the :class:`aud.SequenceEntry` class. We can use this entry to mute the note in case it's actually a pause. + +.. code-block:: python + + if char == 'p': + entry.muted = True + +Lastly we have to update our position variable. + +.. code-block:: python + + position += length + +Now in **tetris2.py** we used the :data:`aud.SequenceEntry.muted` property to show how the :class:`aud.SequenceEntry` class can be used, but it would actually be smarter to not even create a note for pauses and just skip them. You can try to implement this as an exercise and then check out the solution in **tetris3.py**. + +Conclusion +---------- + +We introduced all five currently available classes in the audaspace Python API. Of course all classes offer a lot more functions than have been used in these demo applications, check out the specific class documentation for more details. |