palace
Advanced tools
| # Listener pytest module | ||
| # Copyright (C) 2020 Ngô Xuân Minh | ||
| # | ||
| # This file is part of palace. | ||
| # | ||
| # 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. | ||
| # | ||
| # palace is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with palace. If not, see <https://www.gnu.org/licenses/>. | ||
| """This pytest module tries to test the correctness of the class Listener.""" | ||
| from pytest import raises | ||
| from math import inf | ||
| def test_gain(context): | ||
| """Test write property gain.""" | ||
| context.listener.gain = 5/7 | ||
| context.listener.gain = 7/5 | ||
| context.listener.gain = 0 | ||
| context.listener.gain = inf | ||
| with raises(ValueError): context.listener.gain = -1 | ||
| def test_position(context): | ||
| """Test write property position.""" | ||
| context.listener.position = 1, 0, 1 | ||
| context.listener.position = 1, 0, -1 | ||
| context.listener.position = 1, -1, 0 | ||
| context.listener.position = 1, 1, 0 | ||
| context.listener.position = 0, 0, 0 | ||
| context.listener.position = 1, 1, 1 | ||
| def test_velocity(context): | ||
| """Test write property velocity.""" | ||
| context.listener.velocity = 420, 0, 69 | ||
| context.listener.velocity = 69, 0, -420 | ||
| context.listener.velocity = 0, 420, -69 | ||
| context.listener.velocity = 0, 0, 42 | ||
| context.listener.velocity = 0, 0, 0 | ||
| context.listener.velocity = 420, 69, 420 | ||
| def test_orientaion(context): | ||
| """Test write property orientation.""" | ||
| context.listener.orientation = (420, 0, 69), (0, 42, 0) | ||
| context.listener.orientation = (69, 0, -420), (0, -69, 420) | ||
| context.listener.orientation = (0, 420, -69), (420, -69, 69) | ||
| context.listener.orientation = (0, 0, 42), (-420, -420, 0) | ||
| context.listener.orientation = (0, 0, 0), (-420, -69, -69) | ||
| context.listener.orientation = (420, 69, 420), (69, -420, 0) | ||
| def test_meters_per_unit(context): | ||
| """Test write property meter_per_unit.""" | ||
| context.listener.meters_per_unit = 4/9 | ||
| context.listener.meters_per_unit = 9/4 | ||
| with raises(ValueError): context.listener.meters_per_unit = 0 | ||
| context.listener.meters_per_unit = inf | ||
| with raises(ValueError): context.listener.meters_per_unit = -1 |
@@ -22,3 +22,3 @@ #!/usr/bin/env python3 | ||
| from palace import device_names, Device | ||
| from palace import device_names, Device, Context | ||
@@ -41,2 +41,9 @@ | ||
| print('ALC version: {}.{}'.format(*args.device.alc_version)) | ||
| with Context(args.device) as ctx: | ||
| default_idx = ctx.default_resampler_index | ||
| resamplers = ctx.available_resamplers | ||
| resamplers[default_idx] += ' (default)' | ||
| print('Available resamplers:', *resamplers, sep='\n ') | ||
| efx = args.device.efx_version | ||
@@ -43,0 +50,0 @@ if efx == (0, 0): |
@@ -35,2 +35,3 @@ #!/usr/bin/env python3 | ||
| with Device(device) as dev, Context(dev) as ctx, Source() as src: | ||
| print('Opened', dev.name) | ||
| for filename in files: | ||
@@ -42,3 +43,4 @@ try: | ||
| decoder.play(CHUNK_LEN, QUEUE_SIZE, src) | ||
| print('Playing: ', filename) | ||
| print(f'Playing {filename} ({decoder.sample_type},', | ||
| f'{decoder.channel_config}, {decoder.frequency} Hz)') | ||
| while src.playing: | ||
@@ -45,0 +47,0 @@ print('Offset:', round(src.offset_seconds), 's - Latency:', |
@@ -26,4 +26,3 @@ #!/usr/bin/env python3 | ||
| from palace import (reverb_preset_names, decode, | ||
| Device, Context, Source, AuxiliaryEffectSlot, Effect) | ||
| from palace import reverb_preset_names, decode, Device, Context, Source, Effect | ||
@@ -36,2 +35,3 @@ CHUNK_LEN: int = 12000 | ||
| class PresetPrinter(Action): | ||
| """CLI action to print available preset names and exit.""" | ||
| def __call__(self, parser: ArgumentParser, *args, **kwargs) -> None: | ||
@@ -53,7 +53,6 @@ print('Available reverb preset names:', *reverb_preset_names, sep='\n') | ||
| print('Opened', dev.name) | ||
| with Source() as src, AuxiliaryEffectSlot() as slot, Effect() as fx: | ||
| with Source() as src, Effect() as fx: | ||
| print('Loading reverb preset', reverb) | ||
| fx.reverb_preset = reverb | ||
| slot.effect = fx | ||
| src.auxiliary_send = slot, 0 | ||
| src.sends[0].effect = fx | ||
@@ -60,0 +59,0 @@ for filename in files: |
@@ -20,5 +20,5 @@ #!/usr/bin/env python3 | ||
| from argparse import Action, ArgumentParser | ||
| from argparse import ArgumentParser | ||
| from functools import partial | ||
| from math import pi | ||
| from operator import not_ | ||
| from random import random | ||
@@ -28,5 +28,5 @@ from time import sleep | ||
| from numpy import arange, float32, ndarray, pi, sin, vectorize | ||
| from palace import Buffer, Context, BaseDecoder, Device | ||
| from numpy import arange, float32, ndarray, sin, vectorize | ||
| from scipy.signal import sawtooth, square, unit_impulse | ||
| from scipy.signal import sawtooth, square | ||
@@ -37,4 +37,4 @@ WAVEFORMS: Dict[str, Callable[[ndarray], ndarray]] = { | ||
| 'sawtooth': sawtooth, | ||
| 'triangle': partial(sawtooth, 0.5), | ||
| 'impulse': lambda frames: unit_impulse(len(frames)), | ||
| 'triangle': partial(sawtooth, width=0.5), | ||
| 'impulse': vectorize(not_), | ||
| 'white-noise': vectorize(lambda time: random())} | ||
@@ -44,2 +44,3 @@ | ||
| class ToneGenerator(BaseDecoder): | ||
| """Generator of elementary signals.""" | ||
| def __init__(self, waveform: str, duration: float, frequency: float): | ||
@@ -77,15 +78,11 @@ self.func = lambda frames: WAVEFORMS[waveform]( | ||
| class TypePrinter(Action): | ||
| def __call__(self, parser: ArgumentParser, *args, **kwargs) -> None: | ||
| print('Available waveform types:', *WAVEFORMS, sep='\n') | ||
| parser.exit() | ||
| def play(device: str, waveform: str, | ||
| duration: float, frequency: float) -> None: | ||
| """Play waveform at the given frequency for given duration.""" | ||
| with Device(device) as dev, Context(dev): | ||
| print('Opened', dev.name) | ||
| dec = ToneGenerator(waveform, duration, frequency) | ||
| with Buffer.from_decoder(dec, 'tonegen') as buf, buf.play() as src: | ||
| while src.playing: | ||
| sleep() | ||
| print(f'Playing {waveform} signal at {frequency} Hz for {duration} s') | ||
| with Buffer.from_decoder(dec, 'tonegen') as buf, buf.play(): | ||
| sleep(duration) | ||
@@ -95,12 +92,10 @@ | ||
| parser = ArgumentParser() | ||
| parser.add_argument('-t', '--types', nargs=0, action=TypePrinter, | ||
| help='print available waveform types in this example') | ||
| parser.add_argument('-w', '--waveform', default='sine', type=str, | ||
| parser.add_argument('-d', '--device', default='', help='device name') | ||
| parser.add_argument('-w', '--waveform', default='sine', choices=WAVEFORMS, | ||
| help='waveform to be generated, default to sine') | ||
| parser.add_argument('-d', '--device', default='', help='device name') | ||
| parser.add_argument('-l', '--duration', default=5.0, type=float, | ||
| help='duration, in second') | ||
| parser.add_argument('-l', '--duration', default=1.0, type=float, | ||
| help='duration in second, default to 1.0') | ||
| parser.add_argument('-f', '--frequency', default=440.0, type=float, | ||
| help='frequency for the wave in hertz, default to 440') | ||
| help='wave frequency in hertz, default to 440.0') | ||
| args = parser.parse_args() | ||
| play(args.device, args.waveform, args.duration, args.frequency) |
+12
-10
| Metadata-Version: 2.1 | ||
| Name: palace | ||
| Version: 0.1.2 | ||
| Version: 0.1.3 | ||
| Summary: Pythonic Audio Library and Codecs Environment | ||
@@ -38,9 +38,6 @@ Home-page: https://github.com/McSinyx/palace | ||
| Wheel distributions are only built for GNU/Linux and macOS on amd64 | ||
| at the time of writing. If you want to help out, please head to | ||
| GitHub issue [#1][GH-1]. | ||
| Wheel distributions are built exclusively for amd64. Currently, only GNU/Linux | ||
| is properly supported. If you want to help packaging for Windows and macOS, | ||
| see [GH-1] and [GH-63] respectively on our issues tracker on GitHub. | ||
| *Note: [Wheels built for macOS have yet to include shared libraries][GH-63], | ||
| so it still requires [alure] and its dependencies to be installed.* | ||
| ### From source | ||
@@ -56,6 +53,10 @@ Aside from the build dependencies listed in `pyproject.toml`, one will | ||
| One may start with the `examples` for sample usage of palace. | ||
| For further information, Python's `help` is your friend. | ||
| For further information, Python's `help` is your friend and | ||
| the API is also available for [online reference][API]. | ||
| ## License and Credits | ||
| Palace is released under the [GNU LGPL version 3 or later][LGPLv3+]. | ||
| Palace is free software: you can redistribute it and/or modify it | ||
| under the terms of the [GNU Lesser General Public License][LGPLv3+] | ||
| as published by the Free Software Foundation, either version 3 | ||
| of the License, or (at your option) any later version. | ||
@@ -83,6 +84,7 @@ To ensure that palace can run without any dependencies outside of the [pip] | ||
| [CMake]: https://cmake.org/ | ||
| [API]: https://mcsinyx.github.io/palace/html/reference.html | ||
| [LGPLv3+]: https://www.gnu.org/licenses/lgpl-3.0.en.html | ||
| [Vorbis]: https://xiph.org/vorbis/ | ||
| [Opus]: http://opus-codec.org/ | ||
| [libsndfile]: http://www.mega-nerd.com/libsndfile/ | ||
| [LGPLv3+]: https://www.gnu.org/licenses/lgpl-3.0.en.html | ||
@@ -89,0 +91,0 @@ Keywords: openal,alure,hrtf |
@@ -31,2 +31,3 @@ CMakeLists.txt | ||
| tests/test_context.py | ||
| tests/test_listener.py | ||
| tests/test_source.py |
+12
-10
| Metadata-Version: 2.1 | ||
| Name: palace | ||
| Version: 0.1.2 | ||
| Version: 0.1.3 | ||
| Summary: Pythonic Audio Library and Codecs Environment | ||
@@ -38,9 +38,6 @@ Home-page: https://github.com/McSinyx/palace | ||
| Wheel distributions are only built for GNU/Linux and macOS on amd64 | ||
| at the time of writing. If you want to help out, please head to | ||
| GitHub issue [#1][GH-1]. | ||
| Wheel distributions are built exclusively for amd64. Currently, only GNU/Linux | ||
| is properly supported. If you want to help packaging for Windows and macOS, | ||
| see [GH-1] and [GH-63] respectively on our issues tracker on GitHub. | ||
| *Note: [Wheels built for macOS have yet to include shared libraries][GH-63], | ||
| so it still requires [alure] and its dependencies to be installed.* | ||
| ### From source | ||
@@ -56,6 +53,10 @@ Aside from the build dependencies listed in `pyproject.toml`, one will | ||
| One may start with the `examples` for sample usage of palace. | ||
| For further information, Python's `help` is your friend. | ||
| For further information, Python's `help` is your friend and | ||
| the API is also available for [online reference][API]. | ||
| ## License and Credits | ||
| Palace is released under the [GNU LGPL version 3 or later][LGPLv3+]. | ||
| Palace is free software: you can redistribute it and/or modify it | ||
| under the terms of the [GNU Lesser General Public License][LGPLv3+] | ||
| as published by the Free Software Foundation, either version 3 | ||
| of the License, or (at your option) any later version. | ||
@@ -83,6 +84,7 @@ To ensure that palace can run without any dependencies outside of the [pip] | ||
| [CMake]: https://cmake.org/ | ||
| [API]: https://mcsinyx.github.io/palace/html/reference.html | ||
| [LGPLv3+]: https://www.gnu.org/licenses/lgpl-3.0.en.html | ||
| [Vorbis]: https://xiph.org/vorbis/ | ||
| [Opus]: http://opus-codec.org/ | ||
| [libsndfile]: http://www.mega-nerd.com/libsndfile/ | ||
| [LGPLv3+]: https://www.gnu.org/licenses/lgpl-3.0.en.html | ||
@@ -89,0 +91,0 @@ Keywords: openal,alure,hrtf |
+11
-9
@@ -30,9 +30,6 @@ # palace | ||
| Wheel distributions are only built for GNU/Linux and macOS on amd64 | ||
| at the time of writing. If you want to help out, please head to | ||
| GitHub issue [#1][GH-1]. | ||
| Wheel distributions are built exclusively for amd64. Currently, only GNU/Linux | ||
| is properly supported. If you want to help packaging for Windows and macOS, | ||
| see [GH-1] and [GH-63] respectively on our issues tracker on GitHub. | ||
| *Note: [Wheels built for macOS have yet to include shared libraries][GH-63], | ||
| so it still requires [alure] and its dependencies to be installed.* | ||
| ### From source | ||
@@ -48,6 +45,10 @@ Aside from the build dependencies listed in `pyproject.toml`, one will | ||
| One may start with the `examples` for sample usage of palace. | ||
| For further information, Python's `help` is your friend. | ||
| For further information, Python's `help` is your friend and | ||
| the API is also available for [online reference][API]. | ||
| ## License and Credits | ||
| Palace is released under the [GNU LGPL version 3 or later][LGPLv3+]. | ||
| Palace is free software: you can redistribute it and/or modify it | ||
| under the terms of the [GNU Lesser General Public License][LGPLv3+] | ||
| as published by the Free Software Foundation, either version 3 | ||
| of the License, or (at your option) any later version. | ||
@@ -75,5 +76,6 @@ To ensure that palace can run without any dependencies outside of the [pip] | ||
| [CMake]: https://cmake.org/ | ||
| [API]: https://mcsinyx.github.io/palace/html/reference.html | ||
| [LGPLv3+]: https://www.gnu.org/licenses/lgpl-3.0.en.html | ||
| [Vorbis]: https://xiph.org/vorbis/ | ||
| [Opus]: http://opus-codec.org/ | ||
| [libsndfile]: http://www.mega-nerd.com/libsndfile/ | ||
| [LGPLv3+]: https://www.gnu.org/licenses/lgpl-3.0.en.html |
+1
-1
| [metadata] | ||
| name = palace | ||
| version = 0.1.2 | ||
| version = 0.1.3 | ||
| url = https://github.com/McSinyx/palace | ||
@@ -5,0 +5,0 @@ author = Nguyễn Gia Phong |
+3
-1
@@ -29,2 +29,3 @@ #!/usr/bin/env python3 | ||
| from os.path import dirname, join | ||
| from platform import system | ||
| from subprocess import DEVNULL, PIPE, run | ||
@@ -36,2 +37,3 @@ | ||
| CPPSTD = '/std:c++14' if system() == 'Windows' else '-std=c++14' | ||
| try: | ||
@@ -87,5 +89,5 @@ TRACE = int(environ['CYTHON_TRACE']) | ||
| define_macros=[('CYTHON_TRACE', TRACE)], | ||
| extra_compile_args=["-std=c++14"], language='c++'), | ||
| extra_compile_args=[CPPSTD], language='c++'), | ||
| compiler_directives=dict( | ||
| binding=True, linetrace=TRACE, language_level='3str', | ||
| c_string_type='str', c_string_encoding='utf8'))) |
+2
-2
@@ -138,4 +138,4 @@ // Helper functions and mappings | ||
| inline alure::FilterParams | ||
| make_filter_params (std::vector<float> params) noexcept | ||
| { return alure::FilterParams {params[0], params[1], params[2]}; } | ||
| make_filter (float gain, float gain_hf, float gain_lf) noexcept | ||
| { return alure::FilterParams {gain, gain_hf, gain_lf}; } | ||
@@ -142,0 +142,0 @@ inline std::vector<float> |
+1
-1
@@ -37,4 +37,4 @@ # Helper functions and mappings | ||
| cdef vector[AttributePair] mkattrs(vector[pair[int, int]]) | ||
| cdef FilterParams make_filter_params(vector[float]) | ||
| cdef FilterParams make_filter(float gain, float gain_hf, float gain_lf) | ||
| cdef vector[float] from_vector3(Vector3) | ||
| cdef Vector3 to_vector3(vector[float]) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
32
3.23%974
6.92%2969940
-6.36%